Skip to content

Commit

Permalink
Initialize all settings from Polymer object when available.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Jun 28, 2019
1 parent e4eb9f2 commit df1eb73
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions lib/utils/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const useNativeCustomElements = !(window.customElements.polyfillWrapFlush
* `rootPath` to provide a stable application mount path when
* using client side routing.
*/
export let rootPath = pathFromUrl(document.baseURI || window.location.href);
export let rootPath = window.Polymer && window.Polymer.rootPath ||
pathFromUrl(document.baseURI || window.location.href);

/**
* Sets the global rootPath property used by `ElementMixin` and
Expand Down Expand Up @@ -51,7 +52,8 @@ export const setRootPath = function(path) {
*
* @type {(function(*,string,string,Node):*)|undefined}
*/
export let sanitizeDOMValue = window.Polymer && window.Polymer.sanitizeDOMValue || undefined;
export let sanitizeDOMValue =
window.Polymer && window.Polymer.sanitizeDOMValue || undefined;

/**
* Sets the global sanitizeDOMValue available via this module's exported
Expand All @@ -70,7 +72,8 @@ export const setSanitizeDOMValue = function(newSanitizeDOMValue) {
* scrolling performance.
* Defaults to `false` for backwards compatibility.
*/
export let passiveTouchGestures = false;
export let passiveTouchGestures =
window.Polymer && window.Polymer.setPassiveTouchGestures || false;

/**
* Sets `passiveTouchGestures` globally for all elements using Polymer Gestures.
Expand All @@ -88,7 +91,8 @@ export const setPassiveTouchGestures = function(usePassive) {
* disallowed, `<dom-bind>` is disabled, and `<dom-if>`/`<dom-repeat>`
* templates will only evaluate in the context of a trusted element template.
*/
export let strictTemplatePolicy = false;
export let strictTemplatePolicy =
window.Polymer && window.Polymer.strictTemplatePolicy || false;

/**
* Sets `strictTemplatePolicy` globally for all elements
Expand All @@ -107,7 +111,8 @@ export const setStrictTemplatePolicy = function(useStrictPolicy) {
* getter and the `html` tag function. To enable legacy loading of templates
* via dom-module, set this flag to true.
*/
export let allowTemplateFromDomModule = false;
export let allowTemplateFromDomModule =
window.Polymer && window.Polymer.allowTemplateFromDomModule || false;

/**
* Sets `lookupTemplateFromDomModule` globally for all elements
Expand All @@ -127,7 +132,8 @@ export const setAllowTemplateFromDomModule = function(allowDomModule) {
* If no includes or relative urls are used in styles, these steps can be
* skipped as an optimization.
*/
export let legacyOptimizations = window.Polymer && window.Polymer.legacyOptimizations || false;
export let legacyOptimizations =
window.Polymer && window.Polymer.legacyOptimizations || false;

/**
* Sets `legacyOptimizations` globally for all elements to enable optimizations
Expand All @@ -144,7 +150,8 @@ export const setLegacyOptimizations = function(useLegacyOptimizations) {
/**
* Setting to add warnings useful when migrating from Polymer 1.x to 2.x.
*/
export let legacyWarnings = false;
export let legacyWarnings =
window.Polymer && window.Polymer.legacyWarnings || false;

/**
* Sets `legacyWarnings` globally for all elements to migration warnings.
Expand All @@ -160,7 +167,8 @@ export const setLegacyWarnings = function(useLegacyWarnings) {
* Setting to perform initial rendering synchronously when running under ShadyDOM.
* This matches the behavior of Polymer 1.
*/
export let syncInitialRender = false;
export let syncInitialRender =
window.Polymer && window.Polymer.syncInitialRender || false;

/**
* Sets `syncInitialRender` globally for all elements to enable synchronous
Expand All @@ -179,7 +187,8 @@ export const setSyncInitialRender = function(useSyncInitialRender) {
* observers around undefined values. Observers and computed property methods
* are not called until no argument is undefined.
*/
export let legacyUndefined = false;
export let legacyUndefined =
window.Polymer && window.Polymer.legacyUndefined || false;

/**
* Sets `legacyUndefined` globally for all elements to enable legacy
Expand All @@ -197,7 +206,8 @@ export const setLegacyUndefined = function(useLegacyUndefined) {
* Setting to retain the legacy Polymer 1 behavior for setting properties. Does
* not batch property sets.
*/
export let legacyNoBatch = false;
export let legacyNoBatch =
window.Polymer && window.Polymer.legacyNoBatch || false;

/**
* Sets `legacyNoBatch` globally for all elements to enable legacy
Expand All @@ -216,7 +226,8 @@ export const setLegacyNoBatch = function(useLegacyNoBatch) {
* fire change events with respect to other effects. In Polymer 1.x they fire
* before observers; in 2.x they fire after all other effect types.
*/
export let legacyNotifyOrder = false;
export let legacyNotifyOrder =
window.Polymer && window.Polymer.legacyNotifyOrder || false;

/**
* Sets `legacyNotifyOrder` globally for all elements to enable legacy
Expand All @@ -233,7 +244,8 @@ export const setLegacyNotifyOrder = function(useLegacyNotifyOrder) {
* Setting to ensure computed properties are computed in order to ensure
* re-computation never occurs in a given turn.
*/
export let orderedComputed = false;
export let orderedComputed =
window.Polymer && window.Polymer.orderedComputed || false;

/**
* Sets `orderedComputed` globally for all elements to enable ordered computed
Expand Down Expand Up @@ -270,7 +282,8 @@ export const setCancelSyntheticClickEvents = function(useCancelSyntheticClickEve
* eliminates most of the tax of needing two elements due to the loss of
* type-extended templates as a result of the V1 specification changes.
*/
export let removeNestedTemplates = false;
export let removeNestedTemplates =
window.Polymer && window.Polymer.removeNestedTemplates || false;

/**
* Sets `removeNestedTemplates` globally, to eliminate nested templates
Expand All @@ -292,7 +305,7 @@ export const setRemoveNestedTemplates = function(useCemoveNestedTemplates) {
* such as `modelForElement` will not be available for nodes stamped by
* `dom-if`.
*/
export let fastDomIf = false;
export let fastDomIf = window.Polymer && window.Polymer.fastDomIf || false;

/**
* Sets `fastDomIf` globally, to put `dom-if` in a performance-optimized mode.
Expand Down

0 comments on commit df1eb73

Please sign in to comment.