From 7909c3e71b299fd100c7af660ab68ae3716b0a25 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Mon, 9 Sep 2013 19:23:05 -0700 Subject: [PATCH] Forcibly wrap SVG nodes with on creation Forcing wrapping seems necessary here: I compared a created within a
with a created inside an and they appear to have exactly the same properties with the exception of .parentNode (and .parentElement), yet the former refuses to show up when appended to an element. As such, I can't find any useful way to write a unit test (testing getMarkupWrap's output doesn't seem particularly useful to me). Fixes #311. Test Plan: With a component that adds a after mounting (such as http://jsfiddle.net/spicyj/hxFVe/), verify that the circle appears in both Chrome and IE9. --- src/vendor/core/getMarkupWrap.js | 51 +++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/src/vendor/core/getMarkupWrap.js b/src/vendor/core/getMarkupWrap.js index 91dac43e19..2b21b275e1 100644 --- a/src/vendor/core/getMarkupWrap.js +++ b/src/vendor/core/getMarkupWrap.js @@ -32,23 +32,52 @@ var dummyNode = * * In IE8, certain elements cannot render alone, so wrap all elements ('*'). */ -var shouldWrap = {}; +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, + 'g': true, + 'line': true, + 'path': true, + 'polyline': true, + 'rect': true, + 'text': true +}; + +var selectWrap = [1, '']; +var tableWrap = [1, '', '
']; +var trWrap = [3, '', '
']; + +var svgWrap = [1, '', '']; + var markupWrap = { + '*': [1, '?
', '
'], + 'area': [1, '', ''], - 'caption': [1, '', '
'], 'col': [2, '', '
'], - 'colgroup': [1, '', '
'], 'legend': [1, '
', '
'], - 'optgroup': [1, ''], - 'option': [1, ''], 'param': [1, '', ''], - 'tbody': [1, '', '
'], - 'td': [3, '', '
'], - 'tfoot': [1, '', '
'], - 'th': [3, '', '
'], - 'thead': [1, '', '
'], 'tr': [2, '', '
'], - '*': [1, '?
', '
'] + + 'optgroup': selectWrap, + 'option': selectWrap, + + 'caption': tableWrap, + 'colgroup': tableWrap, + 'tbody': tableWrap, + 'tfoot': tableWrap, + 'thead': tableWrap, + + 'td': trWrap, + 'th': trWrap, + + 'circle': svgWrap, + 'g': svgWrap, + 'line': svgWrap, + 'path': svgWrap, + 'polyline': svgWrap, + 'rect': svgWrap, + 'text': svgWrap }; /**