Skip to content

Commit 63c7fc0

Browse files
committed
Ensure properties is only called once
1 parent 617cb4c commit 63c7fc0

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/mixins/properties-mixin.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ export const PropertiesMixin = dedupingMixin(superClass => {
8686
if (!constructor.hasOwnProperty(JSCompiler_renameProperty('__ownProperties', constructor))) {
8787
let props = null;
8888

89-
if (constructor.hasOwnProperty(JSCompiler_renameProperty('properties', constructor)) && constructor.properties) {
90-
props = normalizeProperties(constructor.properties);
89+
if (constructor.hasOwnProperty(JSCompiler_renameProperty('properties', constructor))) {
90+
const properties = constructor.properties;
91+
92+
if (properties) {
93+
props = normalizeProperties(properties);
94+
}
9195
}
9296

9397
constructor.__ownProperties = props;

test/unit/polymer.properties-mixin.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
class MyElement extends PropertiesMixin(HTMLElement) {
4545

4646
static get properties() {
47+
this._calledProperties++;
48+
4749
return {
4850
prop: String,
4951
noStomp: String,
@@ -111,6 +113,8 @@
111113
MyElement.prototype._calledReady = 0;
112114
MyElement.prototype._callAttributeChangedCallback = 0;
113115

116+
MyElement.constructor.prototype._calledProperties = 0;
117+
114118
customElements.define('my-element', MyElement);
115119

116120
window.MyElement = MyElement;
@@ -236,6 +240,7 @@
236240
assert.equal(el._calledConnectedCallback, 1);
237241
assert.equal(el._calledReady, 1);
238242
assert.equal(el._callAttributeChangedCallback, 0);
243+
assert.equal(el.constructor._calledProperties, 1);
239244
});
240245

241246
test('listeners', function() {

0 commit comments

Comments
 (0)