Skip to content

Commit

Permalink
Allow custom elements extending native ones
Browse files Browse the repository at this point in the history
...by passing the `is` attribute as the second param to `createElement`.
See http://webcomponents.org/polyfills/custom-elements/
  • Loading branch information
jscissr committed Apr 21, 2016
1 parent b7a2409 commit 3ab514f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ ReactDOMComponent.Mixin = {
div.innerHTML = `<${type}></${type}>`;
el = div.removeChild(div.firstChild);
} else {
el = ownerDocument.createElement(this._currentElement.type);
el = ownerDocument.createElement(this._currentElement.type, props.is || null);
}
} else {
el = ownerDocument.createElementNS(
Expand Down
7 changes: 7 additions & 0 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,13 @@ describe('ReactDOMComponent', function() {
'or use `props.dangerouslySetInnerHTML`. Check the render method of X.'
);
});

it('should support custom elements which extend native elements', function() {
var container = document.createElement('div');
spyOn(document, 'createElement').andCallThrough();
ReactDOM.render(<div is="custom-div" />, container);
expect(document.createElement).toHaveBeenCalledWith('div', 'custom-div');
});
});

describe('updateComponent', function() {
Expand Down

0 comments on commit 3ab514f

Please sign in to comment.