Merge pull request #5261 from Polymer/double-properties-invocation

Ensure properties is only invoked once
This commit is contained in:
Steve Orvell
2018-08-03 14:10:54 -07:00
committed by GitHub
2 changed files with 30 additions and 39 deletions

View File

@@ -17,8 +17,25 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<script type="module" src="../../lib/mixins/properties-mixin.js"></script>
<body>
<dom-module id="my-element">
<script type="module">
<test-fixture id="my-element-attr">
<template>
<my-element prop="attr" camelCase="camelCase"></my-element>
</template>
</test-fixture>
<test-fixture id="sub-element-attr">
<template>
<sub-element prop="attr" prop2="attr" camelCase="camelCase" camelCase2="camelCase2" custom-observed-attr="custom"></sub-element>
</template>
</test-fixture>
<test-fixture id="sub-mixin-element-attr">
<template>
<sub-mixin-element prop="attr" prop2="attr" prop3="attr" mixin="5" custom-observed-attr="custom"></sub-mixin-element>
</template>
</test-fixture>
<script type="module">
import { PropertiesMixin } from '../../lib/mixins/properties-mixin.js';
class Glar {}
@@ -27,6 +44,8 @@ class Blar {}
class MyElement extends PropertiesMixin(HTMLElement) {
static get properties() {
this._calledProperties++;
return {
prop: String,
noStomp: String,
@@ -94,16 +113,11 @@ MyElement.prototype._calledConnectedCallback = 0;
MyElement.prototype._calledReady = 0;
MyElement.prototype._callAttributeChangedCallback = 0;
MyElement.constructor.prototype._calledProperties = 0;
customElements.define('my-element', MyElement);
window.MyElement = MyElement;
</script>
</dom-module>
<dom-module id="sub-element">
<script type="module">
import '../../lib/mixins/properties-mixin.js';
class SubElement extends window.MyElement {
@@ -141,12 +155,6 @@ class SubElement extends window.MyElement {
customElements.define('sub-element', SubElement);
window.SubElement = SubElement;
</script>
</dom-module>
<dom-module id="sub-mixin-element">
<script type="module">
import '../../lib/mixins/properties-mixin.js';
function MyMixin(Base) {
return class extends Base {
@@ -208,29 +216,7 @@ class SubMixinElement extends MyMixin(window.SubElement) {
customElements.define('sub-mixin-element', SubMixinElement);
window.SubMixinElement = SubMixinElement;
</script>
</dom-module>
<test-fixture id="my-element-attr">
<template>
<my-element prop="attr" camelCase="camelCase"></my-element>
</template>
</test-fixture>
<test-fixture id="sub-element-attr">
<template>
<sub-element prop="attr" prop2="attr" camelCase="camelCase" camelCase2="camelCase2" custom-observed-attr="custom"></sub-element>
</template>
</test-fixture>
<test-fixture id="sub-mixin-element-attr">
<template>
<sub-mixin-element prop="attr" prop2="attr" prop3="attr" mixin="5" custom-observed-attr="custom"></sub-mixin-element>
</template>
</test-fixture>
<script type="module">
import '../../lib/mixins/properties-mixin.js';
suite('class extends Polymer.PropertiesMixin', function() {
let el;
@@ -254,6 +240,7 @@ suite('class extends Polymer.PropertiesMixin', function() {
assert.equal(el._calledConnectedCallback, 1);
assert.equal(el._calledReady, 1);
assert.equal(el._callAttributeChangedCallback, 0);
assert.equal(el.constructor._calledProperties, 1);
});
test('listeners', function() {