Revert "Merge pull request #6164 from gaearon/fix-svg"
This reverts commit 4bbd8d25e19e42533ba69c8fc995bb0cd74427bf, reversing changes made to 56c423afd66f7f1363dee87d25795418d5e74a30.
Paul O’Shannessy committed
Mar 9, 2016 at 10:50 UTC
e8005bf01a28b864d9468b0cbd68dcd8f03562e2
2 files changed
+20
-111
src/renderers/dom/shared/ReactDOMComponent.js
+15
-22
@@ -53,13 +53,9 @@ var registrationNameModules = EventPluginRegistry.registrationNameModules;
53
// For quickly matching children type, to test if can be treated as content.
54
var CONTENT_TYPES = {'string': true, 'number': true};
55
56
+var CHILDREN = keyOf({children: null});
57
var STYLE = keyOf({style: null});
58
var HTML = keyOf({__html: null});
58
-var RESERVED_PROPS = {
59
- children: null,
60
- dangerouslySetInnerHTML: null,
61
- suppressContentEditableWarning: null,
62
-};
59
60
function getDeclarationErrorAddendum(internalInstance) {
61
if (internalInstance) {
@@ -639,13 +635,11 @@ ReactDOMComponent.Mixin = {
635
}
636
var markup = null;
637
if (this._tag != null && isCustomComponent(this._tag, props)) {
642
- if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
638
+ if (propKey !== CHILDREN) {
639
markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue);
640
}
641
} else if (this._namespaceURI === DOMNamespaces.svg) {
646
- if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
647
- markup = DOMPropertyOperations.createMarkupForSVGAttribute(propKey, propValue);
648
- }
642
+ markup = DOMPropertyOperations.createMarkupForSVGAttribute(propKey, propValue);
643
} else {
644
markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
645
}
@@ -920,21 +914,20 @@ ReactDOMComponent.Mixin = {
914
deleteListener(this, propKey);
915
}
916
} else if (isCustomComponent(this._tag, nextProps)) {
923
- if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
924
- DOMPropertyOperations.setValueForAttribute(
925
- getNode(this),
926
- propKey,
927
- nextProp
928
- );
917
+ if (propKey === CHILDREN) {
918
+ nextProp = null;
919
}
920
+ DOMPropertyOperations.setValueForAttribute(
921
+ getNode(this),
922
+ propKey,
923
+ nextProp
924
+ );
925
} else if (this._namespaceURI === DOMNamespaces.svg) {
931
- if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
932
- DOMPropertyOperations.setValueForSVGAttribute(
933
- getNode(this),
934
- propKey,
935
- nextProp
936
- );
937
- }
926
+ DOMPropertyOperations.setValueForSVGAttribute(
927
+ getNode(this),
928
+ propKey,
929
+ nextProp
930
+ );
931
} else if (
932
DOMProperty.properties[propKey] ||
933
DOMProperty.isCustomAttribute(propKey)) {
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+5
-89
@@ -238,100 +238,16 @@ describe('ReactDOMComponent', function() {
238
expect(stubStyle.display).toEqual('');
239
});
240
241
- it('should skip reserved props on web components', function() {
241
+ it('should skip child object attribute on web components', function() {
242
var container = document.createElement('div');
243
244
- ReactDOM.render(
245
- <my-component
246
- children={['foo']}
247
- suppressContentEditableWarning={true}
248
- />,
249
- container
250
- );
244
+ // Test initial render to null
245
+ ReactDOM.render(<my-component children={['foo']} />, container);
246
expect(container.firstChild.hasAttribute('children')).toBe(false);
252
- expect(
253
- container.firstChild.hasAttribute('suppressContentEditableWarning')
254
- ).toBe(false);
247
256
- ReactDOM.render(
257
- <my-component
258
- children={['bar']}
259
- suppressContentEditableWarning={false}
260
- />,
261
- container
262
- );
248
+ // Test updates to null
249
+ ReactDOM.render(<my-component children={['foo']} />, container);
250
expect(container.firstChild.hasAttribute('children')).toBe(false);
264
- expect(
265
- container.firstChild.hasAttribute('suppressContentEditableWarning')
266
- ).toBe(false);
267
- });
268
-
269
- it('should skip dangerouslySetInnerHTML on web components', function() {
270
- var container = document.createElement('div');
271
-
272
- ReactDOM.render(
273
- <my-component dangerouslySetInnerHTML={{__html: 'hi'}} />,
274
- container
275
- );
276
- expect(
277
- container.firstChild.hasAttribute('dangerouslySetInnerHTML')
278
- ).toBe(false);
279
-
280
- ReactDOM.render(
281
- <my-component dangerouslySetInnerHTML={{__html: 'bye'}} />,
282
- container
283
- );
284
- expect(
285
- container.firstChild.hasAttribute('dangerouslySetInnerHTML')
286
- ).toBe(false);
287
- });
288
-
289
- it('should skip reserved props on SVG components', function() {
290
- var container = document.createElement('div');
291
-
292
- ReactDOM.render(
293
- <svg
294
- children={['foo']}
295
- suppressContentEditableWarning={true}
296
- />,
297
- container
298
- );
299
- expect(container.firstChild.hasAttribute('children')).toBe(false);
300
- expect(
301
- container.firstChild.hasAttribute('suppressContentEditableWarning')
302
- ).toBe(false);
303
-
304
- ReactDOM.render(
305
- <svg
306
- children={['bar']}
307
- suppressContentEditableWarning={false}
308
- />,
309
- container
310
- );
311
- expect(container.firstChild.hasAttribute('children')).toBe(false);
312
- expect(
313
- container.firstChild.hasAttribute('suppressContentEditableWarning')
314
- ).toBe(false);
315
- });
316
-
317
- it('should skip dangerouslySetInnerHTML on SVG components', function() {
318
- var container = document.createElement('div');
319
-
320
- ReactDOM.render(
321
- <svg dangerouslySetInnerHTML={{__html: 'hi'}} />,
322
- container
323
- );
324
- expect(
325
- container.firstChild.hasAttribute('dangerouslySetInnerHTML')
326
- ).toBe(false);
327
-
328
- ReactDOM.render(
329
- <svg dangerouslySetInnerHTML={{__html: 'bye'}} />,
330
- container
331
- );
332
- expect(
333
- container.firstChild.hasAttribute('dangerouslySetInnerHTML')
334
- ).toBe(false);
251
});
252
253
it('should remove attributes', function() {