1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor, getOwnPropertyNames, getPrototypeOf, hasOwnProperty, isFrozen, keys, seal, setPrototypeOf, } = Object;
|
15 | const { filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, push: ArrayPush, reduce: ArrayReduce, reverse: ArrayReverse, slice: ArraySlice, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
|
16 | const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
|
17 | function isUndefined(obj) {
|
18 | return obj === undefined;
|
19 | }
|
20 | function isTrue$1(obj) {
|
21 | return obj === true;
|
22 | }
|
23 | function isFalse$1(obj) {
|
24 | return obj === false;
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | const AriaPropertyNames = [
|
43 | 'ariaActiveDescendant',
|
44 | 'ariaAtomic',
|
45 | 'ariaAutoComplete',
|
46 | 'ariaBusy',
|
47 | 'ariaChecked',
|
48 | 'ariaColCount',
|
49 | 'ariaColIndex',
|
50 | 'ariaColSpan',
|
51 | 'ariaControls',
|
52 | 'ariaCurrent',
|
53 | 'ariaDescribedBy',
|
54 | 'ariaDetails',
|
55 | 'ariaDisabled',
|
56 | 'ariaErrorMessage',
|
57 | 'ariaExpanded',
|
58 | 'ariaFlowTo',
|
59 | 'ariaHasPopup',
|
60 | 'ariaHidden',
|
61 | 'ariaInvalid',
|
62 | 'ariaKeyShortcuts',
|
63 | 'ariaLabel',
|
64 | 'ariaLabelledBy',
|
65 | 'ariaLevel',
|
66 | 'ariaLive',
|
67 | 'ariaModal',
|
68 | 'ariaMultiLine',
|
69 | 'ariaMultiSelectable',
|
70 | 'ariaOrientation',
|
71 | 'ariaOwns',
|
72 | 'ariaPlaceholder',
|
73 | 'ariaPosInSet',
|
74 | 'ariaPressed',
|
75 | 'ariaReadOnly',
|
76 | 'ariaRelevant',
|
77 | 'ariaRequired',
|
78 | 'ariaRoleDescription',
|
79 | 'ariaRowCount',
|
80 | 'ariaRowIndex',
|
81 | 'ariaRowSpan',
|
82 | 'ariaSelected',
|
83 | 'ariaSetSize',
|
84 | 'ariaSort',
|
85 | 'ariaValueMax',
|
86 | 'ariaValueMin',
|
87 | 'ariaValueNow',
|
88 | 'ariaValueText',
|
89 | 'role',
|
90 | ];
|
91 | const AttrNameToPropNameMap = create(null);
|
92 | const PropNameToAttrNameMap = create(null);
|
93 |
|
94 | forEach.call(AriaPropertyNames, (propName) => {
|
95 |
|
96 |
|
97 |
|
98 | const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, 'aria-'));
|
99 | AttrNameToPropNameMap[attrName] = propName;
|
100 | PropNameToAttrNameMap[propName] = attrName;
|
101 | });
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 | const _globalThis = (function () {
|
111 |
|
112 | if (typeof globalThis === 'object') {
|
113 | return globalThis;
|
114 | }
|
115 | let _globalThis;
|
116 | try {
|
117 |
|
118 | Object.defineProperty(Object.prototype, '__magic__', {
|
119 | get: function () {
|
120 | return this;
|
121 | },
|
122 | configurable: true,
|
123 | });
|
124 |
|
125 |
|
126 |
|
127 | _globalThis = __magic__;
|
128 |
|
129 | delete Object.prototype.__magic__;
|
130 | }
|
131 | catch (ex) {
|
132 |
|
133 | }
|
134 | finally {
|
135 |
|
136 |
|
137 | if (typeof _globalThis === 'undefined') {
|
138 |
|
139 | _globalThis = window;
|
140 | }
|
141 | }
|
142 | return _globalThis;
|
143 | })();
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | const hasNativeSymbolsSupport = Symbol('x').toString() === 'Symbol(x)';
|
158 | const HTML_ATTRIBUTES_TO_PROPERTY = {
|
159 | accesskey: 'accessKey',
|
160 | readonly: 'readOnly',
|
161 | tabindex: 'tabIndex',
|
162 | bgcolor: 'bgColor',
|
163 | colspan: 'colSpan',
|
164 | rowspan: 'rowSpan',
|
165 | contenteditable: 'contentEditable',
|
166 | crossorigin: 'crossOrigin',
|
167 | datetime: 'dateTime',
|
168 | formaction: 'formAction',
|
169 | ismap: 'isMap',
|
170 | maxlength: 'maxLength',
|
171 | minlength: 'minLength',
|
172 | novalidate: 'noValidate',
|
173 | usemap: 'useMap',
|
174 | for: 'htmlFor',
|
175 | };
|
176 | keys(HTML_ATTRIBUTES_TO_PROPERTY).forEach((attrName) => {
|
177 | });
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 | if (!_globalThis.lwcRuntimeFlags) {
|
187 | Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
188 | }
|
189 | const runtimeFlags = _globalThis.lwcRuntimeFlags;
|
190 |
|
191 |
|
192 | function setFeatureFlag(name, value) {
|
193 | const isBoolean = isTrue$1(value) || isFalse$1(value);
|
194 | if (!isBoolean) {
|
195 | const message = `Failed to set the value "${value}" for the runtime feature flag "${name}". Runtime feature flags can only be set to a boolean value.`;
|
196 | if (process.env.NODE_ENV !== 'production') {
|
197 | throw new TypeError(message);
|
198 | }
|
199 | else {
|
200 |
|
201 | console.error(message);
|
202 | return;
|
203 | }
|
204 | }
|
205 | if (isUndefined(featureFlagLookup[name])) {
|
206 |
|
207 | console.warn(`Failed to set the value "${value}" for the runtime feature flag "${name}" because it is undefined. Possible reasons are that 1) it was misspelled or 2) it was removed from the @lwc/features package.`);
|
208 | return;
|
209 | }
|
210 | if (process.env.NODE_ENV !== 'production') {
|
211 |
|
212 | runtimeFlags[name] = value;
|
213 | }
|
214 | else {
|
215 |
|
216 | const runtimeValue = runtimeFlags[name];
|
217 | if (!isUndefined(runtimeValue)) {
|
218 |
|
219 | console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
|
220 | return;
|
221 | }
|
222 | Object.defineProperty(runtimeFlags, name, { value });
|
223 | }
|
224 | }
|
225 |
|
226 |
|
227 | function setFeatureFlagForTest(name, value) {
|
228 | if (process.env.NODE_ENV !== 'production') {
|
229 | return setFeatureFlag(name, value);
|
230 | }
|
231 | }
|
232 |
|
233 | const featureFlagLookup = {
|
234 | ENABLE_REACTIVE_SETTER: null,
|
235 |
|
236 | ENABLE_ELEMENT_PATCH: null,
|
237 | ENABLE_NODE_LIST_PATCH: null,
|
238 | ENABLE_HTML_COLLECTIONS_PATCH: null,
|
239 | ENABLE_NODE_PATCH: null,
|
240 | };
|
241 |
|
242 | export default featureFlagLookup;
|
243 | export { runtimeFlags, setFeatureFlag, setFeatureFlagForTest };
|
244 |
|