Skip to content

Commit

Permalink
Revert "Merge pull request facebook#6164 from gaearon/fix-svg"
Browse files Browse the repository at this point in the history
This reverts commit 4bbd8d2, reversing
changes made to 56c423a.
  • Loading branch information
zpao committed Mar 9, 2016
1 parent ab81999 commit d9b9518
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 111 deletions.
37 changes: 15 additions & 22 deletions src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ var registrationNameModules = EventPluginRegistry.registrationNameModules;
// For quickly matching children type, to test if can be treated as content.
var CONTENT_TYPES = {'string': true, 'number': true};

var CHILDREN = keyOf({children: null});
var STYLE = keyOf({style: null});
var HTML = keyOf({__html: null});
var RESERVED_PROPS = {
children: null,
dangerouslySetInnerHTML: null,
suppressContentEditableWarning: null,
};

function getDeclarationErrorAddendum(internalInstance) {
if (internalInstance) {
Expand Down Expand Up @@ -639,13 +635,11 @@ ReactDOMComponent.Mixin = {
}
var markup = null;
if (this._tag != null && isCustomComponent(this._tag, props)) {
if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
if (propKey !== CHILDREN) {
markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue);
}
} else if (this._namespaceURI === DOMNamespaces.svg) {
if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
markup = DOMPropertyOperations.createMarkupForSVGAttribute(propKey, propValue);
}
markup = DOMPropertyOperations.createMarkupForSVGAttribute(propKey, propValue);
} else {
markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
}
Expand Down Expand Up @@ -920,21 +914,20 @@ ReactDOMComponent.Mixin = {
deleteListener(this, propKey);
}
} else if (isCustomComponent(this._tag, nextProps)) {
if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
DOMPropertyOperations.setValueForAttribute(
getNode(this),
propKey,
nextProp
);
if (propKey === CHILDREN) {
nextProp = null;
}
DOMPropertyOperations.setValueForAttribute(
getNode(this),
propKey,
nextProp
);
} else if (this._namespaceURI === DOMNamespaces.svg) {
if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
DOMPropertyOperations.setValueForSVGAttribute(
getNode(this),
propKey,
nextProp
);
}
DOMPropertyOperations.setValueForSVGAttribute(
getNode(this),
propKey,
nextProp
);
} else if (
DOMProperty.properties[propKey] ||
DOMProperty.isCustomAttribute(propKey)) {
Expand Down
94 changes: 5 additions & 89 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,100 +238,16 @@ describe('ReactDOMComponent', function() {
expect(stubStyle.display).toEqual('');
});

it('should skip reserved props on web components', function() {
it('should skip child object attribute on web components', function() {
var container = document.createElement('div');

ReactDOM.render(
<my-component
children={['foo']}
suppressContentEditableWarning={true}
/>,
container
);
// Test initial render to null
ReactDOM.render(<my-component children={['foo']} />, container);
expect(container.firstChild.hasAttribute('children')).toBe(false);
expect(
container.firstChild.hasAttribute('suppressContentEditableWarning')
).toBe(false);

ReactDOM.render(
<my-component
children={['bar']}
suppressContentEditableWarning={false}
/>,
container
);
// Test updates to null
ReactDOM.render(<my-component children={['foo']} />, container);
expect(container.firstChild.hasAttribute('children')).toBe(false);
expect(
container.firstChild.hasAttribute('suppressContentEditableWarning')
).toBe(false);
});

it('should skip dangerouslySetInnerHTML on web components', function() {
var container = document.createElement('div');

ReactDOM.render(
<my-component dangerouslySetInnerHTML={{__html: 'hi'}} />,
container
);
expect(
container.firstChild.hasAttribute('dangerouslySetInnerHTML')
).toBe(false);

ReactDOM.render(
<my-component dangerouslySetInnerHTML={{__html: 'bye'}} />,
container
);
expect(
container.firstChild.hasAttribute('dangerouslySetInnerHTML')
).toBe(false);
});

it('should skip reserved props on SVG components', function() {
var container = document.createElement('div');

ReactDOM.render(
<svg
children={['foo']}
suppressContentEditableWarning={true}
/>,
container
);
expect(container.firstChild.hasAttribute('children')).toBe(false);
expect(
container.firstChild.hasAttribute('suppressContentEditableWarning')
).toBe(false);

ReactDOM.render(
<svg
children={['bar']}
suppressContentEditableWarning={false}
/>,
container
);
expect(container.firstChild.hasAttribute('children')).toBe(false);
expect(
container.firstChild.hasAttribute('suppressContentEditableWarning')
).toBe(false);
});

it('should skip dangerouslySetInnerHTML on SVG components', function() {
var container = document.createElement('div');

ReactDOM.render(
<svg dangerouslySetInnerHTML={{__html: 'hi'}} />,
container
);
expect(
container.firstChild.hasAttribute('dangerouslySetInnerHTML')
).toBe(false);

ReactDOM.render(
<svg dangerouslySetInnerHTML={{__html: 'bye'}} />,
container
);
expect(
container.firstChild.hasAttribute('dangerouslySetInnerHTML')
).toBe(false);
});

it('should remove attributes', function() {
Expand Down

0 comments on commit d9b9518

Please sign in to comment.