Skip to content

Commit

Permalink
Ensure properties is only called once
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Jun 16, 2018
1 parent 617cb4c commit 63c7fc0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/mixins/properties-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ export const PropertiesMixin = dedupingMixin(superClass => {
if (!constructor.hasOwnProperty(JSCompiler_renameProperty('__ownProperties', constructor))) {
let props = null;

if (constructor.hasOwnProperty(JSCompiler_renameProperty('properties', constructor)) && constructor.properties) {
props = normalizeProperties(constructor.properties);
if (constructor.hasOwnProperty(JSCompiler_renameProperty('properties', constructor))) {
const properties = constructor.properties;

if (properties) {
props = normalizeProperties(properties);
}
}

constructor.__ownProperties = props;
Expand Down
5 changes: 5 additions & 0 deletions test/unit/polymer.properties-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
class MyElement extends PropertiesMixin(HTMLElement) {

static get properties() {
this._calledProperties++;

return {
prop: String,
noStomp: String,
Expand Down Expand Up @@ -111,6 +113,8 @@
MyElement.prototype._calledReady = 0;
MyElement.prototype._callAttributeChangedCallback = 0;

MyElement.constructor.prototype._calledProperties = 0;

customElements.define('my-element', MyElement);

window.MyElement = MyElement;
Expand Down Expand Up @@ -236,6 +240,7 @@
assert.equal(el._calledConnectedCallback, 1);
assert.equal(el._calledReady, 1);
assert.equal(el._callAttributeChangedCallback, 0);
assert.equal(el.constructor._calledProperties, 1);
});

test('listeners', function() {
Expand Down

0 comments on commit 63c7fc0

Please sign in to comment.