Skip to content

Commit

Permalink
Merge branch 'legacy-undefined' into legacy-undefined-noBatch
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Feb 20, 2019
2 parents e29a315 + 8e6b786 commit 4658b08
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 63 deletions.
10 changes: 10 additions & 0 deletions externs/polymer-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ PolymerInit.prototype.template;
PolymerInit.prototype.hostAttributes;
/** @type {(!Object<string, string> | undefined)} */
PolymerInit.prototype.listeners;
/** @type {(!Object| !Array<!Object> | undefined)} */
PolymerInit.prototype.behaviors;

/** @record */
let PolymerElementConstructor = function () {};
Expand Down Expand Up @@ -110,6 +112,8 @@ function JSCompiler_renameProperty(string, obj) {}
function PolymerTelemetry() {}
/** @type {number} */
PolymerTelemetry.instanceCount;
/** @type {function():void} */
PolymerTelemetry.incrementInstanceCount;
/** @type {Array<HTMLElement>} */
PolymerTelemetry.registrations;
/** @type {function(HTMLElement)} */
Expand All @@ -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
Expand Down
10 changes: 7 additions & 3 deletions externs/webcomponents-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var HTMLImports = {
*/
whenReady(callback) {},
/**
* @param {Element} element
* @returns {Document} document
* @param {!Node} element
* @return {?HTMLLinkElement|?Document|undefined}
*/
importForElement(element) {}
};
Expand All @@ -42,7 +42,11 @@ var ShadyDOM = {
/**
* @param {Node} node
*/
patch(node) {}
patch(node) {},
/**
* @param {!ShadowRoot} shadowroot
*/
flushInitial(shadowroot) {}
};

window.ShadyDOM = ShadyDOM;
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/property-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -2239,7 +2239,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;
Expand Down
117 changes: 58 additions & 59 deletions test/unit/legacy-undefined.html
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down Expand Up @@ -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]');
});

});

</script>
Expand Down

0 comments on commit 4658b08

Please sign in to comment.