Skip to content

Commit

Permalink
Properly prefixize references in <style> tag (fixes #27 #50 #53)
Browse files Browse the repository at this point in the history
  • Loading branch information
kisenka committed Oct 14, 2016
1 parent 1301a80 commit a31ea7d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/processings/prefixize.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,25 @@ module.exports = function (doc, prefix) {

$('*').each(function () {
var $elem = $(this);
var isStyleTag = $elem[0].name === 'style';
var attrs = $elem.attr();

if (isStyleTag) {
var content = $elem.text();
var id;
var match;

while ((match = urlPattern.exec(content)) !== null) {
id = match[1];
if (!!mappedIds[id]) {
mappedIds[id].referenced = true;
content = content.replace(match[0], 'url(#' + mappedIds[id].id + ')');
}
}

id && $elem.text(content);
}

Object.keys(attrs).forEach(function (key) {
var value = attrs[key];
var id;
Expand All @@ -56,4 +73,4 @@ module.exports = function (doc, prefix) {
}
});
});
};
};

0 comments on commit a31ea7d

Please sign in to comment.