diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d99bb10b79..d2e675bab4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,6 @@ Beyond GitHub, we try to have a variety of different lines of communication open * [Blog](https://blog.polymer-project.org/) * [Twitter](https://twitter.com/polymer) -* [Google+ Community](https://plus.sandbox.google.com/u/0/communities/115626364525706131031?cfem=1) * [Mailing list](https://groups.google.com/forum/#!forum/polymer-dev) * [Slack channel](https://bit.ly/polymerslack) diff --git a/README.md b/README.md index 58a54a8a2d..b65a090bd4 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,6 @@ Beyond GitHub, we try to have a variety of different lines of communication avai * [Blog](https://blog.polymer-project.org/) * [Twitter](https://twitter.com/polymer) -* [Google+ community](https://plus.google.com/communities/115626364525706131031) * [Mailing list](https://groups.google.com/forum/#!forum/polymer-dev) * [Slack channel](https://bit.ly/polymerslack) diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index a510ecc9cc..b7a04aee65 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -24,7 +24,7 @@ import { wrap } from '../utils/wrap.js'; * Current Polymer version in Semver notation. * @type {string} Semver notation of the current version of Polymer. */ -export const version = '3.0.5'; +export const version = '3.2.0'; const builtCSS = window.ShadyCSS && window.ShadyCSS['cssBuild']; diff --git a/lib/mixins/template-stamp.js b/lib/mixins/template-stamp.js index 156bacee5f..19c00c220b 100644 --- a/lib/mixins/template-stamp.js +++ b/lib/mixins/template-stamp.js @@ -11,9 +11,6 @@ import '../utils/boot.js'; import { dedupingMixin } from '../utils/mixin.js'; -const walker = document.createTreeWalker(document, NodeFilter.SHOW_ALL, - null, false); - // 1.x backwards-compatible auto-wrapper for template type extensions // This is a clear layering violation and gives favored-nation status to // dom-if and dom-repeat templates. This is a conceit we're choosing to keep @@ -48,8 +45,7 @@ function findTemplateNode(root, nodeInfo) { if (parent) { // note: marginally faster than indexing via childNodes // (http://jsperf.com/childnodes-lookup) - walker.currentNode = parent; - for (let n=walker.firstChild(), i=0; n; n=walker.nextSibling()) { + for (let n=parent.firstChild, i=0; n; n=n.nextSibling) { if (nodeInfo.parentIndex === i++) { return n; } @@ -239,8 +235,7 @@ export const TemplateStamp = dedupingMixin( // For ShadyDom optimization, indicating there is an insertion point templateInfo.hasInsertionPoint = true; } - walker.currentNode = element; - if (walker.firstChild()) { + if (element.firstChild) { noted = this._parseTemplateChildNodes(element, templateInfo, nodeInfo) || noted; } if (element.hasAttributes && element.hasAttributes()) { @@ -266,8 +261,7 @@ export const TemplateStamp = dedupingMixin( if (root.localName === 'script' || root.localName === 'style') { return; } - walker.currentNode = root; - for (let node=walker.firstChild(), parentIndex=0, next; node; node=next) { + for (let node=root.firstChild, parentIndex=0, next; node; node=next) { // Wrap templates if (node.localName == 'template') { node = wrapTemplateExtension(node); @@ -276,13 +270,12 @@ export const TemplateStamp = dedupingMixin( // text nodes to be inexplicably split =( // note that root.normalize() should work but does not so we do this // manually. - walker.currentNode = node; - next = walker.nextSibling(); + next = node.nextSibling; if (node.nodeType === Node.TEXT_NODE) { let /** Node */ n = next; while (n && (n.nodeType === Node.TEXT_NODE)) { node.textContent += n.textContent; - next = walker.nextSibling(); + next = n.nextSibling; root.removeChild(n); n = next; } @@ -297,8 +290,7 @@ export const TemplateStamp = dedupingMixin( childInfo.infoIndex = templateInfo.nodeInfoList.push(/** @type {!NodeInfo} */(childInfo)) - 1; } // Increment if not removed - walker.currentNode = node; - if (walker.parentNode()) { + if (node.parentNode) { parentIndex++; } } diff --git a/lib/utils/debounce.js b/lib/utils/debounce.js index 6fb246052b..cf4311abbc 100644 --- a/lib/utils/debounce.js +++ b/lib/utils/debounce.js @@ -35,8 +35,8 @@ export class Debouncer { this._callback = callback; this._timer = this._asyncModule.run(() => { this._timer = null; - this._callback(); debouncerQueue.delete(this); + this._callback(); }); } /** @@ -161,6 +161,5 @@ export const flushDebouncers = function() { }); } }); - debouncerQueue = new Set(); return didFlush; }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 18b8846d8b..1ac0035ba0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@polymer/polymer", - "version": "3.1.0", + "version": "3.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 1ccba888ec..6b89e07f24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polymer/polymer", - "version": "3.1.0", + "version": "3.2.0", "description": "The Polymer library makes it easy to create your own web components. Give your element some markup and properties, and then use it on a site. Polymer provides features like dynamic templates and data binding to reduce the amount of boilerplate you need to write", "main": "polymer-element.js", "directories": { diff --git a/test/unit/debounce.html b/test/unit/debounce.html index 5d20439147..a5a97d599c 100644 --- a/test/unit/debounce.html +++ b/test/unit/debounce.html @@ -38,7 +38,7 @@ suite('enqueueDebouncer & flush', function() { - // NOTE: This is a regression test; the bug it fixed only occured if the + // NOTE: This is a regression test; the bug it fixed only occurred if the // debouncer was flushed before any microtasks run, hence it should be // first in this file test('re-enqueue canceled debouncer', function() { @@ -55,6 +55,16 @@ assert.isTrue(cb.calledOnce); }); + test('flushDebouncers from enqueued debouncer', function(done) { + const cb = sinon.spy(() => flush()); + let db = Debouncer.debounce(null, microTask, cb); + enqueueDebouncer(db); + setTimeout(() => { + assert.isTrue(cb.calledOnce); + done(); + }); + }); + const testEnqueue = (shouldFlush, done) => { const actualOrder = []; const enqueue = (type, {db, cb} = {}) => { @@ -89,6 +99,21 @@ testEnqueue(true, done); }); + test('reentrant flush', function() { + const cb2 = sinon.spy(); + let db2; + const cb1 = sinon.spy(() => { + flush(); + db2 = Debouncer.debounce(null, microTask, cb2); + enqueueDebouncer(db2); + }); + const db1 = Debouncer.debounce(null, microTask, cb1); + enqueueDebouncer(db1); + flush(); + assert.isTrue(cb1.calledOnce); + assert.isTrue(cb2.calledOnce); + }); + }); suite('debounce', function() {