From 35f17979df94f0e1cd2ae9b4deb7606433ea358d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 11 Jun 2013 14:39:34 -0700 Subject: [PATCH] Improve Node.js XMLSerializer workaround for lowercased tagNames. --- src/node/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/node/index.js b/src/node/index.js index a531e24c..715616be 100644 --- a/src/node/index.js +++ b/src/node/index.js @@ -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('(<|