diff --git a/README.md b/README.md index d92ed6f..3a9255b 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,6 @@ A suite of polyfills supporting the [Web Components](http://webcomponents.org) s **Shadow DOM**: provides encapsulation by hiding DOM subtrees under shadow roots ([spec](https://w3c.github.io/webcomponents/spec/shadow/)). -This also folds in polyfills for `MutationObserver` and `WeakMap`. - - ## Releases Pre-built (concatenated & minified) versions of the polyfills are maintained in the [tagged versions](https://github.com/webcomponents/webcomponentsjs/releases) of this repo. There are two variants: @@ -75,9 +72,9 @@ Copyright (c) 2015 The Polymer Authors. All rights reserved. ### `WebComponentsReady` -Under native HTML Imports, ` - - - diff --git a/tests/MutationObserver/transient.js b/tests/MutationObserver/transient.js deleted file mode 100644 index 0a226d0..0000000 --- a/tests/MutationObserver/transient.js +++ /dev/null @@ -1,287 +0,0 @@ -/** - * @license - * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. - * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt - * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt - * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt - * Code distributed by Google as part of the polymer project is also - * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt - */ - -suite('JsMutationObserver transient', function() { - - var testDiv; - - setup(function() { - testDiv = document.body.appendChild(document.createElement('div')); - }); - - teardown(function() { - document.body.removeChild(testDiv); - }); - - test('attr', function() { - var div = testDiv.appendChild(document.createElement('div')); - var child = div.appendChild(document.createElement('div')); - var observer = new JsMutationObserver(function() {}); - observer.observe(div, { - attributes: true, - subtree: true - }); - div.removeChild(child); - child.setAttribute('a', 'A'); - - var records = observer.takeRecords(); - assert.strictEqual(records.length, 1); - - expectRecord(records[0], { - type: 'attributes', - target: child, - attributeName: 'a', - attributeNamespace: null - }); - - child.setAttribute('b', 'B'); - - records = observer.takeRecords(); - assert.strictEqual(records.length, 1); - - expectRecord(records[0], { - type: 'attributes', - target: child, - attributeName: 'b', - attributeNamespace: null - }); - }); - - test('attr callback', function(cont) { - var div = testDiv.appendChild(document.createElement('div')); - var child = div.appendChild(document.createElement('div')); - var i = 0; - var observer = new JsMutationObserver(function(records) { - i++; - if (i > 1) - expect().fail(); - - assert.strictEqual(records.length, 1); - - expectRecord(records[0], { - type: 'attributes', - target: child, - attributeName: 'a', - attributeNamespace: null - }); - - // The transient observers are removed before the callback is called. - child.setAttribute('b', 'B'); - records = observer.takeRecords(); - assert.strictEqual(records.length, 0); - - cont(); - }); - - observer.observe(div, { - attributes: true, - subtree: true - }); - - div.removeChild(child); - child.setAttribute('a', 'A'); - }); - - test('attr, make sure transient gets removed', function(cont) { - var div = testDiv.appendChild(document.createElement('div')); - var child = div.appendChild(document.createElement('div')); - var i = 0; - var observer = new JsMutationObserver(function(records) { - i++; - if (i > 1) - expect().fail(); - - assert.strictEqual(records.length, 1); - - expectRecord(records[0], { - type: 'attributes', - target: child, - attributeName: 'a', - attributeNamespace: null - }); - - step2(); - }); - - observer.observe(div, { - attributes: true, - subtree: true - }); - - div.removeChild(child); - child.setAttribute('a', 'A'); - - function step2() { - var div2 = document.createElement('div'); - var observer2 = new JsMutationObserver(function(records) { - i++; - if (i > 2) - expect().fail(); - - assert.strictEqual(records.length, 1); - - expectRecord(records[0], { - type: 'attributes', - target: child, - attributeName: 'b', - attributeNamespace: null - }); - - cont(); - }); - - observer2.observe(div2, { - attributes: true, - subtree: true, - }); - - div2.appendChild(child); - child.setAttribute('b', 'B'); - } - }); - - test('characterData', function() { - var div = document.createElement('div'); - var child = div.appendChild(document.createTextNode('text')); - var observer = new JsMutationObserver(function() {}); - observer.observe(div, { - characterData: true, - subtree: true - }); - div.removeChild(child); - child.data = 'changed'; - - var records = observer.takeRecords(); - assert.strictEqual(records.length, 1); - - expectRecord(records[0], { - type: 'characterData', - target: child - }); - - child.data += ' again'; - - records = observer.takeRecords(); - assert.strictEqual(records.length, 1); - - expectRecord(records[0], { - type: 'characterData', - target: child - }); - }); - - test('characterData callback', function(cont) { - var div = document.createElement('div'); - var child = div.appendChild(document.createTextNode('text')); - var i = 0; - var observer = new JsMutationObserver(function(records) { - i++; - if (i > 1) - expect().fail(); - - assert.strictEqual(records.length, 1); - - expectRecord(records[0], { - type: 'characterData', - target: child - }); - - // The transient observers are removed before the callback is called. - child.data += ' again'; - records = observer.takeRecords(); - assert.strictEqual(records.length, 0); - - cont(); - }); - observer.observe(div, { - characterData: true, - subtree: true - }); - div.removeChild(child); - child.data = 'changed'; - }); - - test('childList', function() { - var div = testDiv.appendChild(document.createElement('div')); - var child = div.appendChild(document.createElement('div')); - var observer = new JsMutationObserver(function() {}); - observer.observe(div, { - childList: true, - subtree: true - }); - div.removeChild(child); - var grandChild = child.appendChild(document.createElement('span')); - - var records = observer.takeRecords(); - assert.strictEqual(records.length, 2); - - expectRecord(records[0], { - type: 'childList', - target: div, - removedNodes: [child] - }); - - expectRecord(records[1], { - type: 'childList', - target: child, - addedNodes: [grandChild] - }); - - child.removeChild(grandChild); - - records = observer.takeRecords(); - assert.strictEqual(records.length, 1); - - expectRecord(records[0], { - type: 'childList', - target: child, - removedNodes: [grandChild] - }); - }); - - test('childList callback', function(cont) { - var div = testDiv.appendChild(document.createElement('div')); - var child = div.appendChild(document.createElement('div')); - var i = 0; - var observer = new JsMutationObserver(function(records) { - i++; - if (i > 1) - expect().fail(); - - assert.strictEqual(records.length, 2); - - expectRecord(records[0], { - type: 'childList', - target: div, - removedNodes: [child] - }); - - expectRecord(records[1], { - type: 'childList', - target: child, - addedNodes: [grandChild] - }); - - // The transient observers are removed before the callback is called. - child.removeChild(grandChild); - - records = observer.takeRecords(); - assert.strictEqual(records.length, 0); - - cont(); - }); - observer.observe(div, { - childList: true, - subtree: true - }); - div.removeChild(child); - var grandChild = child.appendChild(document.createElement('span')); - }); -}); diff --git a/tests/ShadowDOM/html/full-suite.html b/tests/ShadowDOM/html/full-suite.html index ecf6039..20fd4c4 100644 --- a/tests/ShadowDOM/html/full-suite.html +++ b/tests/ShadowDOM/html/full-suite.html @@ -94,7 +94,6 @@ function expectMutationRecord(record, expected) { -