Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Dont ignore xlinkHref
Browse files Browse the repository at this point in the history
  • Loading branch information
jukben committed May 15, 2019
1 parent 22feca6 commit 169aa2b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/babel/pbfied.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const { parse, transform } = require("@babel/core");
const REMOVE_ATTRS = ["clipRule", "fillRule"];
// specific remove
const PATH_REMOVE_ATTRS = [];
const USE_REMOVE_ATTRS = [];
const SVG_REMOVE_ATTRS = ["width", "height"];
const USE_REMOVE_ATTRS = ["xlinkHref"];

const CLASS_NAME = `pb-icon`;

Expand Down Expand Up @@ -75,10 +75,15 @@ const pbfiedPlugin = ({ types: t }, options) => {
}

// apply scoped IDs for url(#...)
if (
const isFunctionTakingId =
t.isStringLiteral(path.node.value) &&
/\(#[\w-]*\)/.test(path.node.value.value)
) {
/\(#[\w-]*\)/.test(path.node.value.value);

const isXlink =
path.node.name.name === "xlinkHref" &&
t.isStringLiteral(path.node.value);

if (isFunctionTakingId || isXlink) {
path.node.value.value = path.node.value.value.replace(
"#",
`#${options.name}_`
Expand Down

0 comments on commit 169aa2b

Please sign in to comment.