From e35a1a7cfc7e459beee1a3b9cea828fd4bdf8891 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Thu, 7 Feb 2019 11:45:13 -0800 Subject: [PATCH 1/3] Update externs from internal --- externs/polymer-externs.js | 10 ++++++++++ externs/webcomponents-externs.js | 10 +++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/externs/polymer-externs.js b/externs/polymer-externs.js index 8c426f3703..0c7b8ea458 100644 --- a/externs/polymer-externs.js +++ b/externs/polymer-externs.js @@ -47,6 +47,8 @@ PolymerInit.prototype.template; PolymerInit.prototype.hostAttributes; /** @type {(!Object | undefined)} */ PolymerInit.prototype.listeners; +/** @type {(!Object| !Array | undefined)} */ +PolymerInit.prototype.behaviors; /** @record */ let PolymerElementConstructor = function () {}; @@ -110,6 +112,8 @@ function JSCompiler_renameProperty(string, obj) {} function PolymerTelemetry() {} /** @type {number} */ PolymerTelemetry.instanceCount; +/** @type {function():void} */ +PolymerTelemetry.incrementInstanceCount; /** @type {Array} */ PolymerTelemetry.registrations; /** @type {function(HTMLElement)} */ @@ -125,6 +129,12 @@ Polymer.telemetry; /** @type {string} */ Polymer.version; +/** @type {boolean} */ +Polymer.legacyOptimizations; + +/** @type {boolean} */ +Polymer.syncInitialRender; + // nb. This is explicitly 'var', as Closure Compiler checks that this is the case. /** * @constructor diff --git a/externs/webcomponents-externs.js b/externs/webcomponents-externs.js index 99708b9e16..1d796ded48 100644 --- a/externs/webcomponents-externs.js +++ b/externs/webcomponents-externs.js @@ -18,8 +18,8 @@ var HTMLImports = { */ whenReady(callback) {}, /** - * @param {Element} element - * @returns {Document} document + * @param {!Node} element + * @return {?HTMLLinkElement|?Document|undefined} */ importForElement(element) {} }; @@ -42,7 +42,11 @@ var ShadyDOM = { /** * @param {Node} node */ - patch(node) {} + patch(node) {}, + /** + * @param {!ShadowRoot} shadowroot + */ + flushInitial(shadowroot) {} }; window.ShadyDOM = ShadyDOM; From 6139e8893a281f45554337a8a8f059c98b7d58f0 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Wed, 13 Feb 2019 18:16:52 -0800 Subject: [PATCH 2/3] Add arg length check --- lib/mixins/property-effects.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mixins/property-effects.js b/lib/mixins/property-effects.js index dccf2a0051..5e0e2b753d 100644 --- a/lib/mixins/property-effects.js +++ b/lib/mixins/property-effects.js @@ -2226,7 +2226,7 @@ export const PropertyEffects = dedupingMixin(superClass => { } // When the `legacyUndefined` flag is enabled, pass a no-op value // so that the observer, computed property, or compound binding is aborted. - if (legacyUndefined && value === undefined) { + if (legacyUndefined && value === undefined && args.length > 1) { return NOOP; } values[i] = value; From 32c308372c469a07a5c6f63ff87f280cca97201c Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Thu, 14 Feb 2019 09:27:15 -0800 Subject: [PATCH 3/3] Fix test With `legacyUndefined` only multi-property effects should not be run when an argument is undefined; single property effects should always run. --- test/unit/legacy-undefined.html | 117 ++++++++++++++++---------------- 1 file changed, 58 insertions(+), 59 deletions(-) diff --git a/test/unit/legacy-undefined.html b/test/unit/legacy-undefined.html index 2afffd7cb8..78d86304ce 100644 --- a/test/unit/legacy-undefined.html +++ b/test/unit/legacy-undefined.html @@ -211,7 +211,7 @@ setupElement({singleProp}); assertEffects({singlePropObserver: 1}); el.singleProp = undefined; - assertEffects({singlePropObserver: 1}); + assertEffects({singlePropObserver: 2}); }); test('one multiPropObserver arguments undefined', () => { setupElement({multiProp1, multiProp2}); @@ -277,65 +277,64 @@ teardown(() => console.warn.restore()); - suite('warn', () => { - test('no arguments defined', () => { - el = fixture('declarative-none'); - assertEffects({}); - }); - test('singlePropObserver argument defined', () => { - el = fixture('declarative-single'); - assertEffects({singlePropObserver: 1}); - }); - test('one multiPropObserver arguments defined', () => { - el = fixture('declarative-multi-one'); - assertEffects({multiPropObserver: 0}); - }); - test('all multiPropObserver defined', () => { - el = fixture('declarative-multi-all'); - assertEffects({multiPropObserver: 1}); - }); - test('computeSingle argument defined', () => { - el = fixture('declarative-single-computed'); - assertEffects({computeSingle: 1}); - assert.equal(el.computedSingle, '[a]'); - }); - test('one computeMulti arguments defined', () => { - el = fixture('declarative-multi-one-computed'); - assertEffects({computeMulti: 0}); - assert.equal(el.computedMulti, undefined); - }); - test('all computeMulti defined', () => { - el = fixture('declarative-multi-all-computed'); - assert.equal(el.computedMulti, '[b,c]'); - }); - test('inline computeSingle argument defined', () => { - el = fixture('declarative-single-computed-inline'); - assertEffects({computeSingle: 1}); - assert.equal(el.$.child.computedSingle, '[a]'); - }); - test('inline one computeMulti arguments defined', () => { - el = fixture('declarative-multi-one-computed-inline'); - assertEffects({computeMulti: 0}); - assert.equal(el.$.child.computedMulti, undefined); - }); - test('inline all computeMulti defined', () => { - el = fixture('declarative-multi-all-computed-inline'); - assertEffects({computeMulti: 1}); - assert.equal(el.$.child.computedMulti, '[b,c]'); - }); - test('one inline computeMulti argument defined in dom-if', () => { - el = fixture('declarative-multi-if-one-computed-inline'); - flush(); - assertEffects({computeMulti: 0}); - assert.equal(el.$$('#ifChild').computedMulti, undefined); - }); - test('all inline computeMulti argument defined in dom-if', () => { - el = fixture('declarative-multi-if-all-computed-inline'); - flush(); - assertEffects({computeMulti: 1}); - assert.equal(el.$$('#ifChild').computedMulti, '[b,c]'); - }); + test('no arguments defined', () => { + el = fixture('declarative-none'); + assertEffects({}); + }); + test('singlePropObserver argument defined', () => { + el = fixture('declarative-single'); + assertEffects({singlePropObserver: 1}); + }); + test('one multiPropObserver arguments defined', () => { + el = fixture('declarative-multi-one'); + assertEffects({multiPropObserver: 0}); }); + test('all multiPropObserver defined', () => { + el = fixture('declarative-multi-all'); + assertEffects({multiPropObserver: 1}); + }); + test('computeSingle argument defined', () => { + el = fixture('declarative-single-computed'); + assertEffects({computeSingle: 1}); + assert.equal(el.computedSingle, '[a]'); + }); + test('one computeMulti arguments defined', () => { + el = fixture('declarative-multi-one-computed'); + assertEffects({computeMulti: 0}); + assert.equal(el.computedMulti, undefined); + }); + test('all computeMulti defined', () => { + el = fixture('declarative-multi-all-computed'); + assert.equal(el.computedMulti, '[b,c]'); + }); + test('inline computeSingle argument defined', () => { + el = fixture('declarative-single-computed-inline'); + assertEffects({computeSingle: 1}); + assert.equal(el.$.child.computedSingle, '[a]'); + }); + test('inline one computeMulti arguments defined', () => { + el = fixture('declarative-multi-one-computed-inline'); + assertEffects({computeMulti: 0}); + assert.equal(el.$.child.computedMulti, undefined); + }); + test('inline all computeMulti defined', () => { + el = fixture('declarative-multi-all-computed-inline'); + assertEffects({computeMulti: 1}); + assert.equal(el.$.child.computedMulti, '[b,c]'); + }); + test('one inline computeMulti argument defined in dom-if', () => { + el = fixture('declarative-multi-if-one-computed-inline'); + flush(); + assertEffects({computeMulti: 0}); + assert.equal(el.$$('#ifChild').computedMulti, undefined); + }); + test('all inline computeMulti argument defined in dom-if', () => { + el = fixture('declarative-multi-if-all-computed-inline'); + flush(); + assertEffects({computeMulti: 1}); + assert.equal(el.$$('#ifChild').computedMulti, '[b,c]'); + }); + });