Added webcomponents.js and a simple unit test verifying a document fragment as a valid React container.

This commit is contained in:
Jim 2015-02-17 16:32:18 -08:00
parent 73f4dc59d8
commit 12059299f3
2 changed files with 6408 additions and 0 deletions

View File

@ -17,6 +17,13 @@ describe('ReactMount', function() {
var React = require('React');
var ReactMount = require('ReactMount');
var ReactTestUtils = require('ReactTestUtils');
var WebComponents = undefined;
try {
WebComponents = require('WebComponents');
} catch(e) {
/* leave WebComponents undefined */
}
describe('constructAndRenderComponentByID', function() {
it('throws if given an id for a component that doesn\'t exist', function() {
@ -157,4 +164,28 @@ describe('ReactMount', function() {
'Rendering components directly into document.body is discouraged'
);
});
(WebComponents === undefined ? xit : it)
('should allow mounting/unmounting to document fragment container', function() {
var shadowRoot;
var proto = Object.create(HTMLElement.prototype, {
createdCallback: {
value: function() {
var query = encodeURIComponent(this.innerHTML);
var url = "https://www.google.com/search?q=" + query + "&btnI";
shadowRoot = this.createShadowRoot();
React.render(<div>Hi, from within a WC!</div>, shadowRoot);
expect(shadowRoot.firstChild.tagName).toBe('DIV')
React.render(<span>Hi, from within a WC!</span>, shadowRoot);
expect(shadowRoot.firstChild.tagName).toBe('SPAN')
}
}
});
proto.unmount = function() {
React.unmountComponentAtNode(shadowRoot);
}
document.registerElement('x-foo', {prototype: proto});
var element = document.createElement('x-foo');
element.unmount();
});
});

6377
src/vendor/third_party/webcomponents.js vendored Executable file

File diff suppressed because it is too large Load Diff