diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..bb3f440 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,19 @@ +# License + +Everything in this repo is BSD style license unless otherwise specified. + +Copyright (c) 2015 The Polymer Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. +* Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index 23dcc3a..49ed2b6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ webcomponents.js ================ +[![Join the chat at https://gitter.im/webcomponents/webcomponentsjs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/webcomponents/webcomponentsjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + A suite of polyfills supporting the [Web Components](http://webcomponents.org) specs: **Custom Elements**: allows authors to define their own custom tags ([spec](https://w3c.github.io/webcomponents/spec/custom/)). @@ -21,6 +23,28 @@ Pre-built (concatenated & minified) versions of the polyfills are maintained in `webcomponents-lite.js` includes all polyfills except for shadow DOM. +## Browser Support + +Our polyfills are intended to work in the latest versions of evergreen browsers. See below +for our complete browser support matrix: + +| Polyfill | IE10 | IE11+ | Chrome* | Firefox* | Safari 7+* | Chrome Android* | Mobile Safari* | +| ---------- |:----:|:-----:|:-------:|:--------:|:----------:|:---------------:|:--------------:| +| Custom Elements | ~ | ✓ | ✓ | ✓ | ✓ | ✓| ✓ | +| HTML Imports | ~ | ✓ | ✓ | ✓ | ✓| ✓| ✓ | +| Shadow DOM | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| Templates | ✓ | ✓ | ✓ | ✓| ✓ | ✓ | ✓ | + + +*Indicates the current version of the browser + +~Indicates support may be flaky. If using Custom Elements or HTML Imports with Shadow DOM, +you will get the non-flaky Mutation Observer polyfill that Shadow DOM includes. + +The polyfills may work in older browsers, however require additional polyfills (such as classList) +to be used. We cannot guarantee support for browsers outside of our compatibility matrix. + + ### Manually Building If you wish to build the polyfills yourself, you'll need `node` and `gulp` on your system: @@ -41,4 +65,9 @@ The builds will be placed into the `dist/` directory. See the [contributing guide](CONTRIBUTING.md) +## License + +Everything in this repository is BSD style license unless otherwise specified. + +Copyright (c) 2015 The Polymer Authors. All rights reserved. diff --git a/bower.json b/bower.json index 0f74cab..d874884 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "webcomponentsjs", "main": "webcomponents.js", - "version": "0.5.4", + "version": "0.5.5", "homepage": "http://webcomponents.org", "authors": [ "The Polymer Authors" diff --git a/package.json b/package.json index db8bfab..52fdd0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webcomponents.js", - "version": "0.5.4", + "version": "0.5.5", "description": "webcomponents.js", "main": "webcomponents.js", "directories": { diff --git a/src/CustomElements/CustomElements.js b/src/CustomElements/CustomElements.js index 8ef94e6..7b770b4 100644 --- a/src/CustomElements/CustomElements.js +++ b/src/CustomElements/CustomElements.js @@ -28,7 +28,6 @@ var file = 'CustomElements.js'; var modules = [ '../WeakMap/WeakMap.js', - '../MutationObserver/MutationObserver.js', 'base.js', 'traverse.js', 'observe.js', diff --git a/src/CustomElements/build.json b/src/CustomElements/build.json index f8407cd..1723a0a 100644 --- a/src/CustomElements/build.json +++ b/src/CustomElements/build.json @@ -1,6 +1,5 @@ [ "../WeakMap/WeakMap.js", - "../MutationObserver/MutationObserver.js", "base.js", "traverse.js", "observe.js", diff --git a/src/CustomElements/observe.js b/src/CustomElements/observe.js index 6a3f3b2..a7b1ca2 100644 --- a/src/CustomElements/observe.js +++ b/src/CustomElements/observe.js @@ -163,7 +163,7 @@ function inDocument(element) { if (p == doc) { return true; } - p = p.parentNode || p.host; + p = p.parentNode || ((p.nodeType === Node.DOCUMENT_FRAGMENT_NODE) && p.host); } } @@ -293,7 +293,6 @@ function upgradeDocumentTree(doc) { // undefined to aid feature detection of Shadow DOM. var originalCreateShadowRoot = Element.prototype.createShadowRoot; if (originalCreateShadowRoot) { - // ensure that all ShadowRoots watch for CustomElements. Element.prototype.createShadowRoot = function() { var root = originalCreateShadowRoot.call(this); CustomElements.watchShadow(this); diff --git a/src/HTMLImports/HTMLImports.js b/src/HTMLImports/HTMLImports.js index 2b76f5d..bf3f12d 100644 --- a/src/HTMLImports/HTMLImports.js +++ b/src/HTMLImports/HTMLImports.js @@ -27,7 +27,6 @@ var file = 'HTMLImports.js'; var modules = [ '../WeakMap/WeakMap.js', - '../MutationObserver/MutationObserver.js', 'base.js', 'module.js', 'path.js', diff --git a/src/HTMLImports/base.js b/src/HTMLImports/base.js index f12f8f8..d86d298 100644 --- a/src/HTMLImports/base.js +++ b/src/HTMLImports/base.js @@ -115,24 +115,35 @@ function markTargetLoaded(event) { // call when we ensure all imports have loaded function watchImportsLoad(callback, doc) { var imports = doc.querySelectorAll('link[rel=import]'); - var loaded = 0, l = imports.length; - function checkDone(d) { - if ((loaded == l) && callback) { - callback(); + var parsedCount = 0, importCount = imports.length, newImports = [], errorImports = []; + function checkDone() { + if (parsedCount == importCount && callback) { + callback({ + allImports: imports, + loadedImports: newImports, + errorImports: errorImports + }); } } function loadedImport(e) { markTargetLoaded(e); - loaded++; + newImports.push(this); + parsedCount++; checkDone(); } - if (l) { - for (var i=0, imp; (i + + + + HTML Imports Dynamic + + + + + + + + + diff --git a/tests/HTMLImports/html/dynamic-errors-detail.html b/tests/HTMLImports/html/dynamic-errors-detail.html new file mode 100644 index 0000000..c10ce16 --- /dev/null +++ b/tests/HTMLImports/html/dynamic-errors-detail.html @@ -0,0 +1,50 @@ + + + + + HTML Imports Dynamic + + + + + + + + + diff --git a/tests/HTMLImports/html/dynamic-loaded-detail.html b/tests/HTMLImports/html/dynamic-loaded-detail.html new file mode 100644 index 0000000..6d963aa --- /dev/null +++ b/tests/HTMLImports/html/dynamic-loaded-detail.html @@ -0,0 +1,50 @@ + + + + + HTML Imports Dynamic + + + + + + + + + diff --git a/tests/HTMLImports/tests.js b/tests/HTMLImports/tests.js index 83f0879..ee82f91 100644 --- a/tests/HTMLImports/tests.js +++ b/tests/HTMLImports/tests.js @@ -21,6 +21,9 @@ htmlSuite('HTMLImports', function() { htmlTest('html/currentScript.html'); htmlTest('html/dedupe.html'); htmlTest('html/dynamic.html'); + htmlTest('html/dynamic-all-imports-detail.html'); + htmlTest('html/dynamic-errors-detail.html'); + htmlTest('html/dynamic-loaded-detail.html'); htmlTest('html/csp.html'); htmlTest('html/customevent-detail.html'); htmlTest('html/encoding.html'); diff --git a/tests/MutationObservers/childList.js b/tests/MutationObservers/childList.js index a54f915..ab24c37 100644 --- a/tests/MutationObservers/childList.js +++ b/tests/MutationObservers/childList.js @@ -378,4 +378,25 @@ suite('JsMutationObserver childList', function() { }); }); + test('Append child in child', function() { + var div = testDiv.appendChild(document.createElement('div')); + + var observer = new JsMutationObserver(function() {}); + observer.observe(div, { + childList: true, + subtree: true + }); + var div2 = document.createElement('div') + var div3 = div2.appendChild(document.createElement('div')); + div.appendChild(div2); + var records = observer.takeRecords(); + + if(records.length == 1) { + assert.strictEqual(records[0].target, div); + assert.strictEqual(records[0].addedNodes[0].firstChild, div3); + } else { + assert.strictEqual(records[0].target, div); + assert.strictEqual(records[1].target, div2); + } + }); }); diff --git a/tests/MutationObservers/runner.html b/tests/MutationObservers/runner.html index ea8c3bc..d5b0406 100644 --- a/tests/MutationObservers/runner.html +++ b/tests/MutationObservers/runner.html @@ -17,6 +17,7 @@ + + + + + + + +
red
+ + + diff --git a/tests/ShadowCSS/tests.js b/tests/ShadowCSS/tests.js index d3435ba..121ed1d 100644 --- a/tests/ShadowCSS/tests.js +++ b/tests/ShadowCSS/tests.js @@ -25,5 +25,6 @@ htmlSuite('ShadowCss', function() { htmlTest('html/before-content.html?shadow'); htmlTest('html/before-content.html'); htmlTest('html/style-import.html'); + htmlTest('html/style-import-base-tag.html'); htmlTest('html/css-animation.html'); }); diff --git a/tests/ShadowDOM/js/DOMTokenList.js b/tests/ShadowDOM/js/DOMTokenList.js index 217004d..411b270 100644 --- a/tests/ShadowDOM/js/DOMTokenList.js +++ b/tests/ShadowDOM/js/DOMTokenList.js @@ -9,6 +9,13 @@ */ suite('DOMTokenList', function() { + if (!window.DOMTokenList) { + test('classList returns undefined if not supported', function() { + var div = document.createElement('div'); + assert.isUndefined(div.classList); + }); + return; + } test('instanceof', function() { var div = document.createElement('div'); diff --git a/webcomponents.js b/webcomponents.js index 2d090df..8112c73 100644 --- a/webcomponents.js +++ b/webcomponents.js @@ -34,7 +34,7 @@ } } // log flags - if (flags.log) { + if (flags.log && flags.log.split) { var parts = flags.log.split(','); flags.log = {}; parts.forEach(function(f) {