Skip to content

Commit

Permalink
Merge pull request #5583 from Polymer/legacy-undefined-noBatch-fastDo…
Browse files Browse the repository at this point in the history
…mIfFlush

Ensure clients are flushed when runtime stamping via `_stampTemplate`.
  • Loading branch information
kevinpschaaf authored Aug 27, 2019
2 parents 2656060 + 8b69933 commit ee6b49a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 54 deletions.
1 change: 1 addition & 0 deletions lib/mixins/property-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -2845,6 +2845,7 @@ export const PropertyEffects = dedupingMixin(superClass => {
// are run at this point during the initial element boot-up.
if (this.__dataClientsReady) {
this._runEffectsForTemplate(templateInfo, this.__data, null, false);
this._flushClients();
}
return dom;
}
Expand Down
119 changes: 65 additions & 54 deletions test/unit/property-effects-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
}
ready() {
super.ready();
this.readied = true;
window.lifecycleOrder.log(this, 'ready');
}
}
Expand Down Expand Up @@ -153,6 +154,9 @@
this.shadowRoot.appendChild(dom);
return dom;
}
stampNoAppend() {
return this._stampTemplate(this.$.templateFromShadowDom);
}
}
customElements.define('x-runtime', XRuntime);
</script>
Expand Down Expand Up @@ -304,6 +308,7 @@
},
idFor(el) {
let host = el.getRootNode().host;
host = host && host.localName !== 'x-runtime' ? host : null;
let id = el.getAttribute('log') || el.id;
return (host ? this.idFor(host) + '|' : '') + el.localName + (id ? '#' + id : '');
}
Expand Down Expand Up @@ -356,9 +361,9 @@
assert.equal(stamped[0], el.$.first);
// Lifecycle order correct
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
'x-element#proto|x-element-child#noBinding',
'x-element#proto|x-element-child#hasBinding',
'x-element#proto',
'x-runtime'
]);
});
Expand All @@ -372,13 +377,13 @@
assert.equal(stamped[0], el.$.first);
assert.equal(stamped[1], dom.$.first);
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
'x-element#proto|x-element-child#noBinding',
'x-element#proto|x-element-child#hasBinding',
'x-element#proto',
'x-runtime',
'x-runtime|x-element#shadow|x-element-child#noBinding',
'x-runtime|x-element#shadow|x-element-child#hasBinding',
'x-runtime|x-element#shadow'
'x-element#shadow|x-element-child#noBinding',
'x-element#shadow|x-element-child#hasBinding',
'x-element#shadow'
]);
});

Expand Down Expand Up @@ -419,19 +424,19 @@
assert.equal(stamped[1], dom2.$.first);
assert.equal(stamped[2], dom3.$.first);
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
'x-element#proto|x-element-child#noBinding',
'x-element#proto|x-element-child#hasBinding',
'x-element#proto',
'x-runtime',
'x-runtime|x-element#shadow|x-element-child#noBinding',
'x-runtime|x-element#shadow|x-element-child#hasBinding',
'x-runtime|x-element#shadow',
'x-runtime|x-element#shadow|x-element-child#noBinding',
'x-runtime|x-element#shadow|x-element-child#hasBinding',
'x-runtime|x-element#shadow',
'x-runtime|x-element#shadow|x-element-child#noBinding',
'x-runtime|x-element#shadow|x-element-child#hasBinding',
'x-runtime|x-element#shadow'
'x-element#shadow|x-element-child#noBinding',
'x-element#shadow|x-element-child#hasBinding',
'x-element#shadow',
'x-element#shadow|x-element-child#noBinding',
'x-element#shadow|x-element-child#hasBinding',
'x-element#shadow',
'x-element#shadow|x-element-child#noBinding',
'x-element#shadow|x-element-child#hasBinding',
'x-element#shadow'
]);
// Unstamp
el._removeBoundDom(dom2);
Expand All @@ -456,9 +461,9 @@
assert.equal(stamped[0], el.$.first);
assert.equal(stamped[1], dom.$.first);
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
'x-element#proto|x-element-child#noBinding',
'x-element#proto|x-element-child#hasBinding',
'x-element#proto',
'x-runtime',
'x-element#shadow|x-element-child#noBinding',
'x-element#shadow|x-element-child#hasBinding',
Expand Down Expand Up @@ -503,19 +508,19 @@
assert.equal(stamped[1], dom2.$.first);
assert.equal(stamped[2], dom3.$.first);
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
'x-element#proto|x-element-child#noBinding',
'x-element#proto|x-element-child#hasBinding',
'x-element#proto',
'x-runtime',
'x-element#shadow|x-element-child#noBinding',
'x-element#shadow|x-element-child#hasBinding',
'x-element#shadow',
'x-runtime|x-element#shadow|x-element-child#noBinding',
'x-runtime|x-element#shadow|x-element-child#hasBinding',
'x-runtime|x-element#shadow',
'x-runtime|x-element#shadow|x-element-child#noBinding',
'x-runtime|x-element#shadow|x-element-child#hasBinding',
'x-runtime|x-element#shadow'
'x-element#shadow|x-element-child#noBinding',
'x-element#shadow|x-element-child#hasBinding',
'x-element#shadow',
'x-element#shadow|x-element-child#noBinding',
'x-element#shadow|x-element-child#hasBinding',
'x-element#shadow'
]);
// Unstamp
el._removeBoundDom(dom2);
Expand All @@ -540,13 +545,13 @@
assert.equal(stamped[0], el.$.first);
assert.equal(stamped[1], dom.$.first);
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
'x-element#proto|x-element-child#noBinding',
'x-element#proto|x-element-child#hasBinding',
'x-element#proto',
'x-runtime',
'x-runtime|x-element#light|x-element-child#noBinding',
'x-runtime|x-element#light|x-element-child#hasBinding',
'x-runtime|x-element#light'
'x-element#light|x-element-child#noBinding',
'x-element#light|x-element-child#hasBinding',
'x-element#light'
]);
});

Expand Down Expand Up @@ -584,19 +589,19 @@
assert.equal(stamped[1], dom2.$.first);
assert.equal(stamped[2], dom3.$.first);
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
'x-element#proto|x-element-child#noBinding',
'x-element#proto|x-element-child#hasBinding',
'x-element#proto',
'x-runtime',
'x-runtime|x-element#light|x-element-child#noBinding',
'x-runtime|x-element#light|x-element-child#hasBinding',
'x-runtime|x-element#light',
'x-runtime|x-element#light|x-element-child#noBinding',
'x-runtime|x-element#light|x-element-child#hasBinding',
'x-runtime|x-element#light',
'x-runtime|x-element#light|x-element-child#noBinding',
'x-runtime|x-element#light|x-element-child#hasBinding',
'x-runtime|x-element#light'
'x-element#light|x-element-child#noBinding',
'x-element#light|x-element-child#hasBinding',
'x-element#light',
'x-element#light|x-element-child#noBinding',
'x-element#light|x-element-child#hasBinding',
'x-element#light',
'x-element#light|x-element-child#noBinding',
'x-element#light|x-element-child#hasBinding',
'x-element#light'
]);
// Unstamp
el._removeBoundDom(dom2);
Expand Down Expand Up @@ -688,12 +693,18 @@
assert.equal(stamped[0], el.$.first);
// Lifecycle order correct
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
'x-element#proto|x-element-child#noBinding',
'x-element#proto|x-element-child#hasBinding',
'x-element#proto',
'x-runtime'
]);
});

test('runtime stamped templates ready before append', () => {
const dom = el.stampNoAppend();
assert.isTrue(dom.querySelector('x-element').readied);
});

});

suite('template parsing hooks', () => {
Expand Down

0 comments on commit ee6b49a

Please sign in to comment.