diff --git a/lib/mixins/property-accessors.js b/lib/mixins/property-accessors.js index bfa7f33a7e..bd2cb77b8a 100644 --- a/lib/mixins/property-accessors.js +++ b/lib/mixins/property-accessors.js @@ -12,6 +12,7 @@ import '../utils/boot.js'; import { dedupingMixin } from '../utils/mixin.js'; import { camelToDashCase, dashToCamelCase } from '../utils/case-map.js'; import { PropertiesChanged } from './properties-changed.js'; +import { legacyNoBatch } from '../utils/settings.js'; // Save map of native properties; this forms a blacklist or properties // that won't have their values "saved" by `saveAccessorValue`, since @@ -289,7 +290,14 @@ export const PropertyAccessors = dedupingMixin(superClass => { * @override */ _definePropertyAccessor(property, readOnly) { - saveAccessorValue(this, property); + if (legacyNoBatch) { + const ready = this.__dataReady; + this.__dataReady = false; + saveAccessorValue(this, property); + this.__dataReady = ready; + } else { + saveAccessorValue(this, property); + } super._definePropertyAccessor(property, readOnly); } diff --git a/lib/mixins/property-effects.js b/lib/mixins/property-effects.js index dccf2a0051..e7412d47a4 100644 --- a/lib/mixins/property-effects.js +++ b/lib/mixins/property-effects.js @@ -19,7 +19,7 @@ import { camelToDashCase, dashToCamelCase } from '../utils/case-map.js'; import { PropertyAccessors } from './property-accessors.js'; /* for annotated effects */ import { TemplateStamp } from './template-stamp.js'; -import { sanitizeDOMValue, legacyUndefined } from '../utils/settings.js'; +import { sanitizeDOMValue, legacyUndefined, legacyNoBatch } from '../utils/settings.js'; // Monotonically increasing unique ID used for de-duping effects triggered // from multiple properties in the same turn @@ -1481,6 +1481,9 @@ export const PropertyEffects = dedupingMixin(superClass => { this.__dataToNotify = this.__dataToNotify || {}; this.__dataToNotify[property] = shouldNotify; } + if (legacyNoBatch) { + this._invalidateProperties(); + } return true; } return false; diff --git a/lib/utils/settings.js b/lib/utils/settings.js index 4d99402006..1f37b9e354 100644 --- a/lib/utils/settings.js +++ b/lib/utils/settings.js @@ -177,3 +177,21 @@ export let legacyUndefined = false; export const setLegacyUndefined = function(useLegacyUndefined) { legacyUndefined = useLegacyUndefined; }; + +/** + * Setting to retain the legacy Polymer 1 behavior for setting properties. Does + * not batch property sets. + */ +export let legacyNoBatch = false; + +/** + * Sets `legacyNoBatch` globally for all elements to enable legacy + * behavior for setting properties. + * + * @param {boolean} useLegacyNoBatch enable or disable legacy + * property setting behavior. + * @return {void} + */ +export const setLegacyNoBatch = function(useLegacyNoBatch) { + legacyNoBatch = useLegacyNoBatch; +};