Skip to content

Commit

Permalink
Merge branch 'legacy-undefined-noBatch' into 5143-kschaaf-ordered-com…
Browse files Browse the repository at this point in the history
…puted-3.x
  • Loading branch information
kevinpschaaf committed Apr 9, 2019
2 parents fc49a92 + 5309a86 commit dae1d73
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 22 deletions.
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/element-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down
20 changes: 6 additions & 14 deletions lib/mixins/template-stamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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()) {
Expand All @@ -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);
Expand All @@ -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;
}
Expand All @@ -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++;
}
}
Expand Down
3 changes: 1 addition & 2 deletions lib/utils/debounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
/**
Expand Down Expand Up @@ -161,6 +161,5 @@ export const flushDebouncers = function() {
});
}
});
debouncerQueue = new Set();
return didFlush;
};
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
27 changes: 26 additions & 1 deletion test/unit/debounce.html
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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} = {}) => {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit dae1d73

Please sign in to comment.