Merge pull request #3176 from jsfb/webcomponent-to-vendor-thirdparty

Added webcomponents.js and a simple unit test verifying a document fragment as a valid React container
This commit is contained in:
Jim
2015-03-16 16:40:22 -07:00
2 changed files with 6408 additions and 0 deletions
@@ -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
View File
File diff suppressed because it is too large Load Diff