Skip to content

Commit

Permalink
Merge pull request #4548 from Polymer/4547-kschaaf-lazy-attachDom
Browse files Browse the repository at this point in the history
Fix test for fallback _readyClients. Fixes #4547
  • Loading branch information
kevinpschaaf authored Apr 19, 2017
2 parents 1478a06 + 7ecbf25 commit 2dccd8e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/mixins/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -1507,14 +1507,14 @@
}

/**
* Overrides PropertyAccessor
* Overrides `PropertyAccessors` to call `_readyClients` callback
* if it was not called as a result of flushing properties.
*
* @override
*/
ready() {
let dataPending = this.__dataPending;
super.ready();
if (!dataPending) {
if (!this.__dataClientsInitialized) {
this._readyClients();
}
}
Expand Down
25 changes: 25 additions & 0 deletions test/unit/configure.html
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,29 @@
};
</script>

<dom-module id="x-config-lazy-nodefaults">
<template>
<div>x-config-lazy-nodefaults</div>
</template>
<script>
window.XConfigLazyNoDefaults = {
is: 'x-config-lazy-nodefaults',
properties: {
prop: {
observer: 'propChanged'
}
},
created: function() {
this.propChanged = sinon.spy();
}
};
</script>
</dom-module>

<dom-module id="x-config-lazy-host">
<template>
<x-config-lazy id="lazy" prop="{{foo}}" read-only-prop="{{foo}}" had-attr-prop="attrValue" bound-no-effect-prop="{{foo}}"></x-config-lazy>
<x-config-lazy-nodefaults prop="[[foo]]"></x-config-lazy-nodefaults>
</template>
<script>
HTMLImports.whenReady(function() {
Expand Down Expand Up @@ -491,6 +511,11 @@
var el = document.createElement('x-config-lazy-host');
document.body.appendChild(el);
Polymer(window.XConfigLazy);
// The purpose of this test is to test lazy upgrading an element that
// has a property pre-bound to it (that has an accessor) but that has
// no defaults for it (stresses a prior bug in ready() code that called
// _attachDom twice, which throws in Safari's native SD
Polymer(window.XConfigLazyNoDefaults);
assert.equal(el.$.lazy.noEffectProp, 1);
assert.equal(el.$.lazy.defaultUsesNoEffectProp, 2);
assert.equal(el.$.lazy.boundNoEffectProp, 'foo');
Expand Down

0 comments on commit 2dccd8e

Please sign in to comment.