-
Notifications
You must be signed in to change notification settings - Fork 2k
/
settings.js
178 lines (160 loc) · 6.17 KB
/
settings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import './boot.js';
import { pathFromUrl } from './resolve-url.js';
export const useShadow = !(window.ShadyDOM);
export const useNativeCSSProperties = Boolean(!window.ShadyCSS || window.ShadyCSS.nativeCss);
export const useNativeCustomElements = !(window.customElements.polyfillWrapFlushCallback);
/**
* Globally settable property that is automatically assigned to
* `ElementMixin` instances, useful for binding in templates to
* make URL's relative to an application's root. Defaults to the main
* document URL, but can be overridden by users. It may be useful to set
* `rootPath` to provide a stable application mount path when
* using client side routing.
*/
export let rootPath = pathFromUrl(document.baseURI || window.location.href);
/**
* Sets the global rootPath property used by `ElementMixin` and
* available via `rootPath`.
*
* @param {string} path The new root path
* @return {void}
*/
export const setRootPath = function(path) {
rootPath = path;
};
/**
* A global callback used to sanitize any value before inserting it into the DOM.
* The callback signature is:
*
* function sanitizeDOMValue(value, name, type, node) { ... }
*
* Where:
*
* `value` is the value to sanitize.
* `name` is the name of an attribute or property (for example, href).
* `type` indicates where the value is being inserted: one of property, attribute, or text.
* `node` is the node where the value is being inserted.
*
* @type {(function(*,string,string,Node):*)|undefined}
*/
export let sanitizeDOMValue = window.Polymer && window.Polymer.sanitizeDOMValue || undefined;
/**
* Sets the global sanitizeDOMValue available via this module's exported
* `sanitizeDOMValue` variable.
*
* @param {(function(*,string,string,Node):*)|undefined} newSanitizeDOMValue the global sanitizeDOMValue callback
* @return {void}
*/
export const setSanitizeDOMValue = function(newSanitizeDOMValue) {
sanitizeDOMValue = newSanitizeDOMValue;
};
/**
* Globally settable property to make Polymer Gestures use passive TouchEvent listeners when recognizing gestures.
* When set to `true`, gestures made from touch will not be able to prevent scrolling, allowing for smoother
* scrolling performance.
* Defaults to `false` for backwards compatibility.
*/
export let passiveTouchGestures = false;
/**
* Sets `passiveTouchGestures` globally for all elements using Polymer Gestures.
*
* @param {boolean} usePassive enable or disable passive touch gestures globally
* @return {void}
*/
export const setPassiveTouchGestures = function(usePassive) {
passiveTouchGestures = usePassive;
};
/**
* Setting to ensure Polymer template evaluation only occurs based on tempates
* defined in trusted script. When true, `<dom-module>` re-registration is
* 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;
/**
* Sets `strictTemplatePolicy` globally for all elements
*
* @param {boolean} useStrictPolicy enable or disable strict template policy
* globally
* @return {void}
*/
export const setStrictTemplatePolicy = function(useStrictPolicy) {
strictTemplatePolicy = useStrictPolicy;
};
/**
* Setting to enable dom-module lookup from Polymer.Element. By default,
* templates must be defined in script using the `static get template()`
* getter and the `html` tag function. To enable legacy loading of templates
* via dom-module, set this flag to true.
*/
export let allowTemplateFromDomModule = false;
/**
* Sets `lookupTemplateFromDomModule` globally for all elements
*
* @param {boolean} allowDomModule enable or disable template lookup
* globally
* @return {void}
*/
export const setAllowTemplateFromDomModule = function(allowDomModule) {
allowTemplateFromDomModule = allowDomModule;
};
/**
* Setting to skip processing style includes and re-writing urls in css styles.
* Normally "included" styles are pulled into the element and all urls in styles
* are re-written to be relative to the containing script url.
* If no includes or relative urls are used in styles, these steps can be
* skipped as an optimization.
*/
export let legacyOptimizations = false;
/**
* Sets `legacyOptimizations` globally for all elements to enable optimizations
* when only legacy based elements are used.
*
* @param {boolean} useLegacyOptimizations enable or disable legacy optimizations
* includes and url rewriting
* @return {void}
*/
export const setLegacyOptimizations = function(useLegacyOptimizations) {
legacyOptimizations = useLegacyOptimizations;
};
/**
* Setting to perform initial rendering synchronously when running under ShadyDOM.
* This matches the behavior of Polymer 1.
*/
export let syncInitialRender = false;
/**
* Sets `syncInitialRender` globally for all elements to enable synchronous
* initial rendering.
*
* @param {boolean} useSyncInitialRender enable or disable synchronous initial
* rendering globally.
* @return {void}
*/
export const setSyncInitialRender = function(useSyncInitialRender) {
syncInitialRender = useSyncInitialRender;
};
/**
* Setting to cancel synthetic click events fired by older mobile browsers. Modern browsers
* no longer fire synthetic click events, and the cancellation behavior can interfere
* when programmatically clicking on elements.
*/
export let cancelSyntheticClickEvents = true;
/**
* Sets `setCancelSyntheticEvents` globally for all elements to cancel synthetic click events.
*
* @param {boolean} useCancelSyntheticClickEvents enable or disable cancelling synthetic
* events
* @return {void}
*/
export const setCancelSyntheticClickEvents = function(useCancelSyntheticClickEvents) {
cancelSyntheticClickEvents = useCancelSyntheticClickEvents;
};