mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Improve Node.js XMLSerializer workaround for lowercased tagNames.
This commit is contained in:
parent
d41f79598e
commit
35f17979df
1 changed files with 11 additions and 4 deletions
|
@ -38,11 +38,18 @@ function XMLSerializer() {
|
|||
|
||||
XMLSerializer.prototype.serializeToString = function(node) {
|
||||
var text = domToHtml(node);
|
||||
// Fix a jsdom issue where linearGradient gets converted to lineargradient:
|
||||
// Fix a jsdom issue where all SVG tagNames are lowercased:
|
||||
// https://github.com/tmpvar/jsdom/issues/620
|
||||
return text.replace(/(linear|radial)gradient/g, function(all, type) {
|
||||
return type + 'Gradient';
|
||||
});
|
||||
var tagNames = ['linearGradient', 'radialGradient', 'clipPath'];
|
||||
for (var i = 0, l = tagNames.length; i < l; i++) {
|
||||
var tagName = tagNames[i];
|
||||
text = text.replace(
|
||||
new RegExp('(<|</)' + tagName.toLowerCase() + '\\b', 'g'),
|
||||
function(all, start) {
|
||||
return start + tagName;
|
||||
});
|
||||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
function DOMParser() {
|
||||
|
|
Loading…
Reference in a new issue