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 1/3] 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`. * From 572a1d895c12b74cf4a89aa451311c6a1beef543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Wed, 17 Jun 2015 10:40:11 -0700 Subject: [PATCH 2/3] Update getMarkupWrap with list of SVG supported in ReactDOM --- src/shared/vendor/core/getMarkupWrap.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/shared/vendor/core/getMarkupWrap.js b/src/shared/vendor/core/getMarkupWrap.js index a13e7f3d43..9e4a5c6ff2 100644 --- a/src/shared/vendor/core/getMarkupWrap.js +++ b/src/shared/vendor/core/getMarkupWrap.js @@ -67,13 +67,16 @@ var svgElements = [ 'g', 'line', 'linearGradient', + 'mask', 'path', + 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'text', + 'tspan', ]; svgElements.forEach((nodeName) => { markupWrap[nodeName] = svgWrap; From efdd75685d5827216691909cbbe79d7183af2cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Wed, 17 Jun 2015 10:40:53 -0700 Subject: [PATCH 3/3] Support SVG image --- src/isomorphic/classic/element/ReactDOM.js | 1 + src/shared/vendor/core/getMarkupWrap.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/isomorphic/classic/element/ReactDOM.js b/src/isomorphic/classic/element/ReactDOM.js index 9648c5dcd2..bf92612104 100644 --- a/src/isomorphic/classic/element/ReactDOM.js +++ b/src/isomorphic/classic/element/ReactDOM.js @@ -157,6 +157,7 @@ var ReactDOM = mapObject({ defs: 'defs', ellipse: 'ellipse', g: 'g', + image: 'image', line: 'line', linearGradient: 'linearGradient', mask: 'mask', diff --git a/src/shared/vendor/core/getMarkupWrap.js b/src/shared/vendor/core/getMarkupWrap.js index 9e4a5c6ff2..23a760ba2c 100644 --- a/src/shared/vendor/core/getMarkupWrap.js +++ b/src/shared/vendor/core/getMarkupWrap.js @@ -65,6 +65,7 @@ var svgElements = [ 'defs', 'ellipse', 'g', + 'image', 'line', 'linearGradient', 'mask',