From 265fdc3eed9bfebeae062dcff06661900df6e39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Wed, 17 Jun 2015 10:37:13 -0700 Subject: [PATCH] Rewrite SVG initialization in getMarkupWrap --- src/shared/vendor/core/getMarkupWrap.js | 59 +++++++++++-------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/src/shared/vendor/core/getMarkupWrap.js b/src/shared/vendor/core/getMarkupWrap.js index 6a7d42081c..a13e7f3d43 100644 --- a/src/shared/vendor/core/getMarkupWrap.js +++ b/src/shared/vendor/core/getMarkupWrap.js @@ -25,24 +25,8 @@ var dummyNode = * * In IE8, certain elements cannot render alone, so wrap all elements ('*'). */ -var shouldWrap = { - // Force wrapping for SVG elements because if they get created inside a
, - // they will be initialized in the wrong namespace (and will not display). - 'circle': true, - 'clipPath': true, - 'defs': true, - 'ellipse': true, - 'g': true, - 'line': true, - 'linearGradient': true, - 'path': true, - 'polygon': true, - 'polyline': true, - 'radialGradient': true, - 'rect': true, - 'stop': true, - 'text': true -}; + +var shouldWrap = {}; var selectWrap = [1, '']; var tableWrap = [1, '', '
']; @@ -70,23 +54,32 @@ var markupWrap = { 'td': trWrap, 'th': trWrap, - - 'circle': svgWrap, - 'clipPath': svgWrap, - 'defs': svgWrap, - 'ellipse': svgWrap, - 'g': svgWrap, - 'line': svgWrap, - 'linearGradient': svgWrap, - 'path': svgWrap, - 'polygon': svgWrap, - 'polyline': svgWrap, - 'radialGradient': svgWrap, - 'rect': svgWrap, - 'stop': svgWrap, - 'text': svgWrap }; +// Initilize the SVG elements since we know they'll always need to be wrapped +// consistently. If they are created inside a
they will be initialized in +// the wrong namespace (and will not display). +var svgElements = [ + 'circle', + 'clipPath', + 'defs', + 'ellipse', + 'g', + 'line', + 'linearGradient', + 'path', + 'polygon', + 'polyline', + 'radialGradient', + 'rect', + 'stop', + 'text', +]; +svgElements.forEach((nodeName) => { + markupWrap[nodeName] = svgWrap; + shouldWrap[nodeName] = true; +}); + /** * Gets the markup wrap configuration for the supplied `nodeName`. *