@lwc/engine-core 2.34.0 → 2.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-core.cjs.js +797 -605
- package/dist/engine-core.js +798 -607
- package/package.json +4 -4
- package/types/framework/main.d.ts +1 -0
- package/types/framework/reporting.d.ts +31 -0
- package/types/framework/utils.d.ts +1 -0
- package/types/framework/vm.d.ts +0 -2
- package/types/index.d.ts +1 -0
- package/types/patches/detect-synthetic-cross-root-aria.d.ts +1 -0
- package/types/shared/logger.d.ts +1 -0
package/dist/engine-core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* proxy-compat-disable */
|
|
2
2
|
import { lwcRuntimeFlags } from '@lwc/features';
|
|
3
3
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
4
|
-
import {
|
|
4
|
+
import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, seal, isFunction as isFunction$1, hasOwnProperty as hasOwnProperty$1, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, isObject, assert, freeze, KEY__SYNTHETIC_MODE, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, isFalse, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, htmlPropertyToAttribute, ArraySlice, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, htmlAttributeToProperty, isString, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, ArrayPop, isNumber, StringReplace, ArrayUnshift, globalThis as globalThis$1, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, ArrayFilter, StringSplit, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift } from '@lwc/shared';
|
|
5
5
|
import { applyAriaReflection } from '@lwc/aria-reflection';
|
|
6
6
|
|
|
7
7
|
/*
|
|
@@ -11,8 +11,7 @@ import { applyAriaReflection } from '@lwc/aria-reflection';
|
|
|
11
11
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
12
12
|
*/
|
|
13
13
|
// Only used in LWC's Karma tests
|
|
14
|
-
|
|
15
|
-
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
14
|
+
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
|
16
15
|
window.addEventListener('test-dummy-flag', () => {
|
|
17
16
|
let hasFlag = false;
|
|
18
17
|
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
@@ -33,94 +32,167 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
|
33
32
|
* SPDX-License-Identifier: MIT
|
|
34
33
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
35
34
|
*/
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
/** Callbacks to invoke when reporting is enabled **/
|
|
36
|
+
const onReportingEnabledCallbacks = [];
|
|
37
|
+
/** The currently assigned reporting dispatcher. */
|
|
38
|
+
let currentDispatcher$1 = noop;
|
|
39
|
+
/**
|
|
40
|
+
* Whether reporting is enabled.
|
|
41
|
+
*
|
|
42
|
+
* Note that this may seem redundant, given you can just check if the currentDispatcher is undefined,
|
|
43
|
+
* but it turns out that Terser only strips out unused code if we use this explicit boolean.
|
|
44
|
+
*/
|
|
45
|
+
let enabled$1 = false;
|
|
46
|
+
const reportingControl = {
|
|
47
|
+
/**
|
|
48
|
+
* Attach a new reporting control (aka dispatcher).
|
|
49
|
+
*
|
|
50
|
+
* @param dispatcher - reporting control
|
|
51
|
+
*/
|
|
52
|
+
attachDispatcher(dispatcher) {
|
|
53
|
+
enabled$1 = true;
|
|
54
|
+
currentDispatcher$1 = dispatcher;
|
|
55
|
+
for (const callback of onReportingEnabledCallbacks) {
|
|
56
|
+
try {
|
|
57
|
+
callback();
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
// This should never happen. But if it does, we don't want one callback to cause another to fail
|
|
61
|
+
// eslint-disable-next-line no-console
|
|
62
|
+
console.error('Could not invoke callback', err);
|
|
63
|
+
}
|
|
44
64
|
}
|
|
65
|
+
onReportingEnabledCallbacks.length = 0; // clear the array
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Detach the current reporting control (aka dispatcher).
|
|
69
|
+
*/
|
|
70
|
+
detachDispatcher() {
|
|
71
|
+
enabled$1 = false;
|
|
72
|
+
currentDispatcher$1 = noop;
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Call a callback when reporting is enabled, or immediately if reporting is already enabled.
|
|
77
|
+
* Will only ever be called once.
|
|
78
|
+
* @param callback
|
|
79
|
+
*/
|
|
80
|
+
function onReportingEnabled(callback) {
|
|
81
|
+
if (enabled$1) {
|
|
82
|
+
// call immediately
|
|
83
|
+
callback();
|
|
45
84
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
callbacks[i]();
|
|
85
|
+
else {
|
|
86
|
+
// call later
|
|
87
|
+
onReportingEnabledCallbacks.push(callback);
|
|
50
88
|
}
|
|
51
89
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Report to the current dispatcher, if there is one.
|
|
92
|
+
* @param reportingEventId
|
|
93
|
+
* @param vm
|
|
94
|
+
*/
|
|
95
|
+
function report(reportingEventId, vm) {
|
|
96
|
+
if (enabled$1) {
|
|
97
|
+
currentDispatcher$1(reportingEventId, vm.tagName, vm.idx);
|
|
60
98
|
}
|
|
61
|
-
ArrayPush$1.call(nextTickCallbackQueue, callback);
|
|
62
99
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
100
|
+
|
|
101
|
+
/*
|
|
102
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
103
|
+
* All rights reserved.
|
|
104
|
+
* SPDX-License-Identifier: MIT
|
|
105
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
106
|
+
*/
|
|
107
|
+
function getComponentTag(vm) {
|
|
108
|
+
return `<${StringToLowerCase.call(vm.tagName)}>`;
|
|
109
|
+
}
|
|
110
|
+
// TODO [#1695]: Unify getComponentStack and getErrorComponentStack
|
|
111
|
+
function getComponentStack(vm) {
|
|
112
|
+
const stack = [];
|
|
113
|
+
let prefix = '';
|
|
114
|
+
while (!isNull(vm.owner)) {
|
|
115
|
+
ArrayPush$1.call(stack, prefix + getComponentTag(vm));
|
|
116
|
+
vm = vm.owner;
|
|
117
|
+
prefix += '\t';
|
|
68
118
|
}
|
|
69
|
-
return
|
|
119
|
+
return ArrayJoin.call(stack, '\n');
|
|
70
120
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const declarations = cssText.split(DECLARATION_DELIMITER);
|
|
78
|
-
for (const declaration of declarations) {
|
|
79
|
-
if (declaration) {
|
|
80
|
-
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
|
81
|
-
if (prop !== undefined && value !== undefined) {
|
|
82
|
-
styleMap[prop.trim()] = value.trim();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
121
|
+
function getErrorComponentStack(vm) {
|
|
122
|
+
const wcStack = [];
|
|
123
|
+
let currentVm = vm;
|
|
124
|
+
while (!isNull(currentVm)) {
|
|
125
|
+
ArrayPush$1.call(wcStack, getComponentTag(currentVm));
|
|
126
|
+
currentVm = currentVm.owner;
|
|
85
127
|
}
|
|
86
|
-
return
|
|
128
|
+
return wcStack.reverse().join('\n\t');
|
|
87
129
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
130
|
+
|
|
131
|
+
/*
|
|
132
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
133
|
+
* All rights reserved.
|
|
134
|
+
* SPDX-License-Identifier: MIT
|
|
135
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
136
|
+
*/
|
|
137
|
+
function addErrorComponentStack(vm, error) {
|
|
138
|
+
if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
|
|
139
|
+
const wcStack = getErrorComponentStack(vm);
|
|
140
|
+
defineProperty(error, 'wcStack', {
|
|
141
|
+
get() {
|
|
142
|
+
return wcStack;
|
|
143
|
+
},
|
|
144
|
+
});
|
|
95
145
|
}
|
|
96
|
-
return result;
|
|
97
146
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
147
|
+
|
|
148
|
+
/*
|
|
149
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
150
|
+
* All rights reserved.
|
|
151
|
+
* SPDX-License-Identifier: MIT
|
|
152
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
153
|
+
*/
|
|
154
|
+
const alreadyLoggedMessages = new Set();
|
|
155
|
+
// Only used in LWC's Karma tests
|
|
156
|
+
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
|
157
|
+
// @ts-ignore
|
|
158
|
+
window.__lwcResetAlreadyLoggedMessages = () => {
|
|
159
|
+
alreadyLoggedMessages.clear();
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function log(method, message, vm, once) {
|
|
163
|
+
let msg = `[LWC ${method}]: ${message}`;
|
|
164
|
+
if (!isUndefined$1(vm)) {
|
|
165
|
+
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
166
|
+
}
|
|
167
|
+
if (once) {
|
|
168
|
+
if (alreadyLoggedMessages.has(msg)) {
|
|
169
|
+
return;
|
|
106
170
|
}
|
|
171
|
+
alreadyLoggedMessages.add(msg);
|
|
107
172
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
throw new Error('refVNodes must be defined when setting a ref');
|
|
173
|
+
// In Jest tests, reduce the warning and error verbosity by not printing the callstack
|
|
174
|
+
if (process.env.NODE_ENV === 'test') {
|
|
175
|
+
/* eslint-disable-next-line no-console */
|
|
176
|
+
console[method](msg);
|
|
177
|
+
return;
|
|
114
178
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
refVNodes[ref] = vnode;
|
|
179
|
+
try {
|
|
180
|
+
throw new Error(msg);
|
|
181
|
+
}
|
|
182
|
+
catch (e) {
|
|
183
|
+
/* eslint-disable-next-line no-console */
|
|
184
|
+
console[method](e);
|
|
122
185
|
}
|
|
123
186
|
}
|
|
187
|
+
function logError(message, vm) {
|
|
188
|
+
log('error', message, vm, false);
|
|
189
|
+
}
|
|
190
|
+
function logWarn(message, vm) {
|
|
191
|
+
log('warn', message, vm, false);
|
|
192
|
+
}
|
|
193
|
+
function logWarnOnce(message, vm) {
|
|
194
|
+
log('warn', message, vm, true);
|
|
195
|
+
}
|
|
124
196
|
|
|
125
197
|
/*
|
|
126
198
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
@@ -256,80 +328,104 @@ function createReactiveObserver(callback) {
|
|
|
256
328
|
* SPDX-License-Identifier: MIT
|
|
257
329
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
258
330
|
*/
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
function
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
vm = vm.owner;
|
|
269
|
-
prefix += '\t';
|
|
270
|
-
}
|
|
271
|
-
return ArrayJoin.call(stack, '\n');
|
|
272
|
-
}
|
|
273
|
-
function getErrorComponentStack(vm) {
|
|
274
|
-
const wcStack = [];
|
|
275
|
-
let currentVm = vm;
|
|
276
|
-
while (!isNull(currentVm)) {
|
|
277
|
-
ArrayPush$1.call(wcStack, getComponentTag(currentVm));
|
|
278
|
-
currentVm = currentVm.owner;
|
|
331
|
+
let nextTickCallbackQueue = [];
|
|
332
|
+
const SPACE_CHAR = 32;
|
|
333
|
+
const EmptyObject = seal(create(null));
|
|
334
|
+
const EmptyArray = seal([]);
|
|
335
|
+
function flushCallbackQueue() {
|
|
336
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
337
|
+
if (nextTickCallbackQueue.length === 0) {
|
|
338
|
+
throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
|
|
339
|
+
}
|
|
279
340
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
285
|
-
* All rights reserved.
|
|
286
|
-
* SPDX-License-Identifier: MIT
|
|
287
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
288
|
-
*/
|
|
289
|
-
function addErrorComponentStack(vm, error) {
|
|
290
|
-
if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
|
|
291
|
-
const wcStack = getErrorComponentStack(vm);
|
|
292
|
-
defineProperty(error, 'wcStack', {
|
|
293
|
-
get() {
|
|
294
|
-
return wcStack;
|
|
295
|
-
},
|
|
296
|
-
});
|
|
341
|
+
const callbacks = nextTickCallbackQueue;
|
|
342
|
+
nextTickCallbackQueue = []; // reset to a new queue
|
|
343
|
+
for (let i = 0, len = callbacks.length; i < len; i += 1) {
|
|
344
|
+
callbacks[i]();
|
|
297
345
|
}
|
|
298
346
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
305
|
-
*/
|
|
306
|
-
function log(method, message, vm) {
|
|
307
|
-
let msg = `[LWC ${method}]: ${message}`;
|
|
308
|
-
if (!isUndefined$1(vm)) {
|
|
309
|
-
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
310
|
-
}
|
|
311
|
-
// In Jest tests, reduce the warning and error verbosity by not printing the callstack
|
|
312
|
-
if (process.env.NODE_ENV === 'test') {
|
|
313
|
-
/* eslint-disable-next-line no-console */
|
|
314
|
-
console[method](msg);
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
try {
|
|
318
|
-
throw new Error(msg);
|
|
347
|
+
function addCallbackToNextTick(callback) {
|
|
348
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
349
|
+
if (!isFunction$1(callback)) {
|
|
350
|
+
throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
|
|
351
|
+
}
|
|
319
352
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
console[method](e);
|
|
353
|
+
if (nextTickCallbackQueue.length === 0) {
|
|
354
|
+
Promise.resolve().then(flushCallbackQueue);
|
|
323
355
|
}
|
|
356
|
+
ArrayPush$1.call(nextTickCallbackQueue, callback);
|
|
324
357
|
}
|
|
325
|
-
function
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
358
|
+
function guid() {
|
|
359
|
+
function s4() {
|
|
360
|
+
return Math.floor((1 + Math.random()) * 0x10000)
|
|
361
|
+
.toString(16)
|
|
362
|
+
.substring(1);
|
|
363
|
+
}
|
|
364
|
+
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
330
365
|
}
|
|
331
|
-
|
|
332
|
-
|
|
366
|
+
// Borrowed from Vue template compiler.
|
|
367
|
+
// https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
|
|
368
|
+
const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
|
|
369
|
+
const PROPERTY_DELIMITER = /:(.+)/;
|
|
370
|
+
function parseStyleText(cssText) {
|
|
371
|
+
const styleMap = {};
|
|
372
|
+
const declarations = cssText.split(DECLARATION_DELIMITER);
|
|
373
|
+
for (const declaration of declarations) {
|
|
374
|
+
if (declaration) {
|
|
375
|
+
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
|
376
|
+
if (prop !== undefined && value !== undefined) {
|
|
377
|
+
styleMap[prop.trim()] = value.trim();
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return styleMap;
|
|
382
|
+
}
|
|
383
|
+
// Make a shallow copy of an object but omit the given key
|
|
384
|
+
function cloneAndOmitKey(object, keyToOmit) {
|
|
385
|
+
const result = {};
|
|
386
|
+
for (const key of Object.keys(object)) {
|
|
387
|
+
if (key !== keyToOmit) {
|
|
388
|
+
result[key] = object[key];
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return result;
|
|
392
|
+
}
|
|
393
|
+
function flattenStylesheets(stylesheets) {
|
|
394
|
+
const list = [];
|
|
395
|
+
for (const stylesheet of stylesheets) {
|
|
396
|
+
if (!Array.isArray(stylesheet)) {
|
|
397
|
+
list.push(stylesheet);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
list.push(...flattenStylesheets(stylesheet));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return list;
|
|
404
|
+
}
|
|
405
|
+
// Set a ref (lwc:ref) on a VM, from a template API
|
|
406
|
+
function setRefVNode(vm, ref, vnode) {
|
|
407
|
+
if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
|
|
408
|
+
throw new Error('refVNodes must be defined when setting a ref');
|
|
409
|
+
}
|
|
410
|
+
// If this method is called, then vm.refVNodes is set as the template has refs.
|
|
411
|
+
// If not, then something went wrong and we threw an error above.
|
|
412
|
+
const refVNodes = vm.refVNodes;
|
|
413
|
+
// In cases of conflict (two elements with the same ref), prefer, the last one,
|
|
414
|
+
// in depth-first traversal order.
|
|
415
|
+
if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
|
|
416
|
+
refVNodes[ref] = vnode;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
// Throw an error if we're running in prod mode. Ensures code is truly removed from prod mode.
|
|
420
|
+
function assertNotProd() {
|
|
421
|
+
/* istanbul ignore if */
|
|
422
|
+
if (process.env.NODE_ENV === 'production') {
|
|
423
|
+
// this method should never leak to prod
|
|
424
|
+
throw new ReferenceError();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/*
|
|
333
429
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
334
430
|
* All rights reserved.
|
|
335
431
|
* SPDX-License-Identifier: MIT
|
|
@@ -381,7 +477,7 @@ function offsetPropertyErrorMessage(name) {
|
|
|
381
477
|
//
|
|
382
478
|
// If you update this list, check for test files that recapitulate the same list. Searching the codebase
|
|
383
479
|
// for e.g. "dropzone" should suffice.
|
|
384
|
-
const globalHTMLProperties =
|
|
480
|
+
const globalHTMLProperties = {
|
|
385
481
|
accessKey: {
|
|
386
482
|
attribute: 'accesskey',
|
|
387
483
|
},
|
|
@@ -466,7 +562,7 @@ const globalHTMLProperties = assign(create(null), {
|
|
|
466
562
|
role: {
|
|
467
563
|
attribute: 'role',
|
|
468
564
|
},
|
|
469
|
-
}
|
|
565
|
+
};
|
|
470
566
|
let controlledElement = null;
|
|
471
567
|
let controlledAttributeName;
|
|
472
568
|
function isAttributeLocked(elm, attrName) {
|
|
@@ -533,27 +629,18 @@ function generateAccessorDescriptor(options) {
|
|
|
533
629
|
}
|
|
534
630
|
let isDomMutationAllowed = false;
|
|
535
631
|
function unlockDomMutation() {
|
|
536
|
-
|
|
537
|
-
// this method should never leak to prod
|
|
538
|
-
throw new ReferenceError();
|
|
539
|
-
}
|
|
632
|
+
assertNotProd(); // this method should never leak to prod
|
|
540
633
|
isDomMutationAllowed = true;
|
|
541
634
|
}
|
|
542
635
|
function lockDomMutation() {
|
|
543
|
-
|
|
544
|
-
// this method should never leak to prod
|
|
545
|
-
throw new ReferenceError();
|
|
546
|
-
}
|
|
636
|
+
assertNotProd(); // this method should never leak to prod
|
|
547
637
|
isDomMutationAllowed = false;
|
|
548
638
|
}
|
|
549
639
|
function logMissingPortalError(name, type) {
|
|
550
640
|
return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
|
|
551
641
|
}
|
|
552
642
|
function patchElementWithRestrictions(elm, options) {
|
|
553
|
-
|
|
554
|
-
// this method should never leak to prod
|
|
555
|
-
throw new ReferenceError();
|
|
556
|
-
}
|
|
643
|
+
assertNotProd(); // this method should never leak to prod
|
|
557
644
|
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
|
558
645
|
const descriptors = {
|
|
559
646
|
outerHTML: generateAccessorDescriptor({
|
|
@@ -634,10 +721,7 @@ function patchElementWithRestrictions(elm, options) {
|
|
|
634
721
|
defineProperties(elm, descriptors);
|
|
635
722
|
}
|
|
636
723
|
function getShadowRootRestrictionsDescriptors(sr) {
|
|
637
|
-
|
|
638
|
-
// this method should never leak to prod
|
|
639
|
-
throw new ReferenceError();
|
|
640
|
-
}
|
|
724
|
+
assertNotProd(); // this method should never leak to prod
|
|
641
725
|
// Disallowing properties in dev mode only to avoid people doing the wrong
|
|
642
726
|
// thing when using the real shadow root, because if that's the case,
|
|
643
727
|
// the component will not work when running with synthetic shadow.
|
|
@@ -678,10 +762,7 @@ function getShadowRootRestrictionsDescriptors(sr) {
|
|
|
678
762
|
// Custom Elements Restrictions:
|
|
679
763
|
// -----------------------------
|
|
680
764
|
function getCustomElementRestrictionsDescriptors(elm) {
|
|
681
|
-
|
|
682
|
-
// this method should never leak to prod
|
|
683
|
-
throw new ReferenceError();
|
|
684
|
-
}
|
|
765
|
+
assertNotProd(); // this method should never leak to prod
|
|
685
766
|
const originalAddEventListener = elm.addEventListener;
|
|
686
767
|
const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
|
687
768
|
const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
|
@@ -726,10 +807,7 @@ function getCustomElementRestrictionsDescriptors(elm) {
|
|
|
726
807
|
};
|
|
727
808
|
}
|
|
728
809
|
function getComponentRestrictionsDescriptors() {
|
|
729
|
-
|
|
730
|
-
// this method should never leak to prod
|
|
731
|
-
throw new ReferenceError();
|
|
732
|
-
}
|
|
810
|
+
assertNotProd(); // this method should never leak to prod
|
|
733
811
|
return {
|
|
734
812
|
tagName: generateAccessorDescriptor({
|
|
735
813
|
get() {
|
|
@@ -743,10 +821,7 @@ function getComponentRestrictionsDescriptors() {
|
|
|
743
821
|
};
|
|
744
822
|
}
|
|
745
823
|
function getLightningElementPrototypeRestrictionsDescriptors(proto) {
|
|
746
|
-
|
|
747
|
-
// this method should never leak to prod
|
|
748
|
-
throw new ReferenceError();
|
|
749
|
-
}
|
|
824
|
+
assertNotProd(); // this method should never leak to prod
|
|
750
825
|
const originalDispatchEvent = proto.dispatchEvent;
|
|
751
826
|
const descriptors = {
|
|
752
827
|
dispatchEvent: generateDataDescriptor({
|
|
@@ -1460,7 +1535,6 @@ function createBridgeToElementDescriptor(propName, descriptor) {
|
|
|
1460
1535
|
}
|
|
1461
1536
|
};
|
|
1462
1537
|
}
|
|
1463
|
-
const EMPTY_REFS = freeze(create(null));
|
|
1464
1538
|
const refsCache = new WeakMap();
|
|
1465
1539
|
/**
|
|
1466
1540
|
* This class is the base class for any LWC element.
|
|
@@ -1748,7 +1822,6 @@ LightningElement.prototype = {
|
|
|
1748
1822
|
}
|
|
1749
1823
|
const {
|
|
1750
1824
|
refVNodes,
|
|
1751
|
-
hasRefVNodes,
|
|
1752
1825
|
cmpTemplate
|
|
1753
1826
|
} = vm;
|
|
1754
1827
|
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
@@ -1762,15 +1835,9 @@ LightningElement.prototype = {
|
|
|
1762
1835
|
// were introduced, we return undefined if the template has no refs defined
|
|
1763
1836
|
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
1764
1837
|
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
1765
|
-
// Note
|
|
1766
|
-
// because a template may have `lwc:ref` defined within a falsy `if:true` block.
|
|
1767
|
-
if (!hasRefVNodes) {
|
|
1768
|
-
return;
|
|
1769
|
-
}
|
|
1770
|
-
// For templates that are using `lwc:ref`, if there are no refs currently available
|
|
1771
|
-
// (e.g. refs inside of a falsy `if:true` block), we return an empty object.
|
|
1838
|
+
// Note we use a null refVNodes to indicate that the template has no refs defined.
|
|
1772
1839
|
if (isNull(refVNodes)) {
|
|
1773
|
-
return
|
|
1840
|
+
return;
|
|
1774
1841
|
}
|
|
1775
1842
|
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
1776
1843
|
// are recreated from scratch every time the template is rendered.
|
|
@@ -1930,109 +1997,286 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
1930
1997
|
* SPDX-License-Identifier: MIT
|
|
1931
1998
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1932
1999
|
*/
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
2000
|
+
const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
|
|
2001
|
+
const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
|
2002
|
+
const WIRE_DEBUG_ENTRY = '@wire';
|
|
2003
|
+
const WireMetaMap = new Map();
|
|
2004
|
+
class WireContextRegistrationEvent extends CustomEvent {
|
|
2005
|
+
constructor(adapterToken, {
|
|
2006
|
+
setNewContext,
|
|
2007
|
+
setDisconnectedCallback
|
|
2008
|
+
}) {
|
|
2009
|
+
super(adapterToken, {
|
|
2010
|
+
bubbles: true,
|
|
2011
|
+
composed: true
|
|
2012
|
+
});
|
|
2013
|
+
defineProperties(this, {
|
|
2014
|
+
setNewContext: {
|
|
2015
|
+
value: setNewContext
|
|
2016
|
+
},
|
|
2017
|
+
setDisconnectedCallback: {
|
|
2018
|
+
value: setDisconnectedCallback
|
|
2019
|
+
}
|
|
2020
|
+
});
|
|
2021
|
+
}
|
|
1938
2022
|
}
|
|
1939
|
-
function
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
if (isBeingConstructed(vm)) {
|
|
1944
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1945
|
-
logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
1946
|
-
}
|
|
1947
|
-
return;
|
|
1948
|
-
}
|
|
1949
|
-
componentValueObserved(vm, key);
|
|
1950
|
-
return vm.cmpProps[key];
|
|
1951
|
-
},
|
|
1952
|
-
set(newValue) {
|
|
1953
|
-
const vm = getAssociatedVM(this);
|
|
1954
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1955
|
-
const vmBeingRendered = getVMBeingRendered();
|
|
1956
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
1957
|
-
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
1958
|
-
}
|
|
1959
|
-
vm.cmpProps[key] = newValue;
|
|
1960
|
-
componentValueMutated(vm, key);
|
|
1961
|
-
},
|
|
1962
|
-
enumerable: true,
|
|
1963
|
-
configurable: true,
|
|
1964
|
-
};
|
|
2023
|
+
function createFieldDataCallback(vm, name) {
|
|
2024
|
+
return value => {
|
|
2025
|
+
updateComponentValue(vm, name, value);
|
|
2026
|
+
};
|
|
1965
2027
|
}
|
|
1966
|
-
function
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
2028
|
+
function createMethodDataCallback(vm, method) {
|
|
2029
|
+
return value => {
|
|
2030
|
+
// dispatching new value into the wired method
|
|
2031
|
+
runWithBoundaryProtection(vm, vm.owner, noop, () => {
|
|
2032
|
+
// job
|
|
2033
|
+
method.call(vm.component, value);
|
|
2034
|
+
}, noop);
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
2038
|
+
let hasPendingConfig = false;
|
|
2039
|
+
// creating the reactive observer for reactive params when needed
|
|
2040
|
+
const ro = createReactiveObserver(() => {
|
|
2041
|
+
if (hasPendingConfig === false) {
|
|
2042
|
+
hasPendingConfig = true;
|
|
2043
|
+
// collect new config in the micro-task
|
|
2044
|
+
Promise.resolve().then(() => {
|
|
2045
|
+
hasPendingConfig = false;
|
|
2046
|
+
// resetting current reactive params
|
|
2047
|
+
ro.reset();
|
|
2048
|
+
// dispatching a new config due to a change in the configuration
|
|
2049
|
+
computeConfigAndUpdate();
|
|
2050
|
+
});
|
|
1973
2051
|
}
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
1988
|
-
}
|
|
1989
|
-
if (set) {
|
|
1990
|
-
set.call(this, newValue);
|
|
1991
|
-
}
|
|
1992
|
-
else if (process.env.NODE_ENV !== 'production') {
|
|
1993
|
-
assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
|
|
1994
|
-
}
|
|
1995
|
-
},
|
|
1996
|
-
enumerable,
|
|
1997
|
-
configurable,
|
|
1998
|
-
};
|
|
2052
|
+
});
|
|
2053
|
+
const computeConfigAndUpdate = () => {
|
|
2054
|
+
let config;
|
|
2055
|
+
ro.observe(() => config = configCallback(component));
|
|
2056
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
2057
|
+
// TODO: dev-mode validation of config based on the adapter.configSchema
|
|
2058
|
+
// @ts-ignore it is assigned in the observe() callback
|
|
2059
|
+
callbackWhenConfigIsReady(config);
|
|
2060
|
+
};
|
|
2061
|
+
return {
|
|
2062
|
+
computeConfigAndUpdate,
|
|
2063
|
+
ro
|
|
2064
|
+
};
|
|
1999
2065
|
}
|
|
2066
|
+
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
2067
|
+
const {
|
|
2068
|
+
adapter
|
|
2069
|
+
} = wireDef;
|
|
2070
|
+
const adapterContextToken = getAdapterToken(adapter);
|
|
2071
|
+
if (isUndefined$1(adapterContextToken)) {
|
|
2072
|
+
return; // no provider found, nothing to be done
|
|
2073
|
+
}
|
|
2000
2074
|
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
return getReactiveProxy(target);
|
|
2010
|
-
}
|
|
2011
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2012
|
-
assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
|
|
2075
|
+
const {
|
|
2076
|
+
elm,
|
|
2077
|
+
context: {
|
|
2078
|
+
wiredConnecting,
|
|
2079
|
+
wiredDisconnecting
|
|
2080
|
+
},
|
|
2081
|
+
renderer: {
|
|
2082
|
+
dispatchEvent
|
|
2013
2083
|
}
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2084
|
+
} = vm;
|
|
2085
|
+
// waiting for the component to be connected to formally request the context via the token
|
|
2086
|
+
ArrayPush$1.call(wiredConnecting, () => {
|
|
2087
|
+
// This event is responsible for connecting the host element with another
|
|
2088
|
+
// element in the composed path that is providing contextual data. The provider
|
|
2089
|
+
// must be listening for a special dom event with the name corresponding to the value of
|
|
2090
|
+
// `adapterContextToken`, which will remain secret and internal to this file only to
|
|
2091
|
+
// guarantee that the linkage can be forged.
|
|
2092
|
+
const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
|
|
2093
|
+
setNewContext(newContext) {
|
|
2094
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
2095
|
+
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
2096
|
+
callbackWhenContextIsReady(newContext);
|
|
2097
|
+
},
|
|
2098
|
+
setDisconnectedCallback(disconnectCallback) {
|
|
2099
|
+
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
2100
|
+
// the the element hosting the wire is disconnected
|
|
2101
|
+
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
2102
|
+
}
|
|
2103
|
+
});
|
|
2104
|
+
dispatchEvent(elm, contextRegistrationEvent);
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2107
|
+
function createConnector(vm, name, wireDef) {
|
|
2108
|
+
const {
|
|
2109
|
+
method,
|
|
2110
|
+
adapter,
|
|
2111
|
+
configCallback,
|
|
2112
|
+
dynamic
|
|
2113
|
+
} = wireDef;
|
|
2114
|
+
let debugInfo;
|
|
2115
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2116
|
+
const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
|
|
2117
|
+
debugInfo = create(null);
|
|
2118
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
2119
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
|
|
2120
|
+
}
|
|
2121
|
+
const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
2122
|
+
const dataCallback = value => {
|
|
2123
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2124
|
+
debugInfo.data = value;
|
|
2125
|
+
// Note: most of the time, the data provided is for the current config, but there may be
|
|
2126
|
+
// some conditions in which it does not, ex:
|
|
2127
|
+
// race conditions in a poor network while the adapter does not cancel a previous request.
|
|
2128
|
+
debugInfo.wasDataProvisionedForConfig = true;
|
|
2129
|
+
}
|
|
2130
|
+
fieldOrMethodCallback(value);
|
|
2131
|
+
};
|
|
2132
|
+
let context;
|
|
2133
|
+
let connector;
|
|
2134
|
+
// Workaround to pass the component element associated to this wire adapter instance.
|
|
2135
|
+
defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
2136
|
+
value: vm.elm
|
|
2137
|
+
});
|
|
2138
|
+
defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
|
|
2139
|
+
value: dynamic
|
|
2140
|
+
});
|
|
2141
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2142
|
+
// job
|
|
2143
|
+
connector = new adapter(dataCallback);
|
|
2144
|
+
}, noop);
|
|
2145
|
+
const updateConnectorConfig = config => {
|
|
2146
|
+
// every time the config is recomputed due to tracking,
|
|
2147
|
+
// this callback will be invoked with the new computed config
|
|
2148
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2149
|
+
// job
|
|
2150
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2151
|
+
debugInfo.config = config;
|
|
2152
|
+
debugInfo.context = context;
|
|
2153
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
2154
|
+
}
|
|
2155
|
+
connector.update(config, context);
|
|
2156
|
+
}, noop);
|
|
2157
|
+
};
|
|
2158
|
+
// Computes the current wire config and calls the update method on the wire adapter.
|
|
2159
|
+
// If it has params, we will need to observe changes in the next tick.
|
|
2160
|
+
const {
|
|
2161
|
+
computeConfigAndUpdate,
|
|
2162
|
+
ro
|
|
2163
|
+
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
2164
|
+
// if the adapter needs contextualization, we need to watch for new context and push it alongside the config
|
|
2165
|
+
if (!isUndefined$1(adapter.contextSchema)) {
|
|
2166
|
+
createContextWatcher(vm, wireDef, newContext => {
|
|
2167
|
+
// every time the context is pushed into this component,
|
|
2168
|
+
// this callback will be invoked with the new computed context
|
|
2169
|
+
if (context !== newContext) {
|
|
2170
|
+
context = newContext;
|
|
2171
|
+
// Note: when new context arrives, the config will be recomputed and pushed along side the new
|
|
2172
|
+
// context, this is to preserve the identity characteristics, config should not have identity
|
|
2173
|
+
// (ever), while context can have identity
|
|
2174
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
2175
|
+
computeConfigAndUpdate();
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
});
|
|
2179
|
+
}
|
|
2180
|
+
return {
|
|
2181
|
+
// @ts-ignore the boundary protection executes sync, connector is always defined
|
|
2182
|
+
connector,
|
|
2183
|
+
computeConfigAndUpdate,
|
|
2184
|
+
resetConfigWatcher: () => ro.reset()
|
|
2185
|
+
};
|
|
2186
|
+
}
|
|
2187
|
+
const AdapterToTokenMap = new Map();
|
|
2188
|
+
function getAdapterToken(adapter) {
|
|
2189
|
+
return AdapterToTokenMap.get(adapter);
|
|
2190
|
+
}
|
|
2191
|
+
function setAdapterToken(adapter, token) {
|
|
2192
|
+
AdapterToTokenMap.set(adapter, token);
|
|
2193
|
+
}
|
|
2194
|
+
function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2195
|
+
// support for callable adapters
|
|
2196
|
+
if (adapter.adapter) {
|
|
2197
|
+
adapter = adapter.adapter;
|
|
2198
|
+
}
|
|
2199
|
+
const method = descriptor.value;
|
|
2200
|
+
const def = {
|
|
2201
|
+
adapter,
|
|
2202
|
+
method,
|
|
2203
|
+
configCallback,
|
|
2204
|
+
dynamic
|
|
2205
|
+
};
|
|
2206
|
+
WireMetaMap.set(descriptor, def);
|
|
2207
|
+
}
|
|
2208
|
+
function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2209
|
+
// support for callable adapters
|
|
2210
|
+
if (adapter.adapter) {
|
|
2211
|
+
adapter = adapter.adapter;
|
|
2212
|
+
}
|
|
2213
|
+
const def = {
|
|
2214
|
+
adapter,
|
|
2215
|
+
configCallback,
|
|
2216
|
+
dynamic
|
|
2217
|
+
};
|
|
2218
|
+
WireMetaMap.set(descriptor, def);
|
|
2219
|
+
}
|
|
2220
|
+
function installWireAdapters(vm) {
|
|
2221
|
+
const {
|
|
2222
|
+
context,
|
|
2223
|
+
def: {
|
|
2224
|
+
wire
|
|
2225
|
+
}
|
|
2226
|
+
} = vm;
|
|
2227
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2228
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
|
|
2229
|
+
}
|
|
2230
|
+
const wiredConnecting = context.wiredConnecting = [];
|
|
2231
|
+
const wiredDisconnecting = context.wiredDisconnecting = [];
|
|
2232
|
+
for (const fieldNameOrMethod in wire) {
|
|
2233
|
+
const descriptor = wire[fieldNameOrMethod];
|
|
2234
|
+
const wireDef = WireMetaMap.get(descriptor);
|
|
2235
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2236
|
+
assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
|
|
2237
|
+
}
|
|
2238
|
+
if (!isUndefined$1(wireDef)) {
|
|
2239
|
+
const {
|
|
2240
|
+
connector,
|
|
2241
|
+
computeConfigAndUpdate,
|
|
2242
|
+
resetConfigWatcher
|
|
2243
|
+
} = createConnector(vm, fieldNameOrMethod, wireDef);
|
|
2244
|
+
const hasDynamicParams = wireDef.dynamic.length > 0;
|
|
2245
|
+
ArrayPush$1.call(wiredConnecting, () => {
|
|
2246
|
+
connector.connect();
|
|
2247
|
+
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
2248
|
+
if (hasDynamicParams) {
|
|
2249
|
+
Promise.resolve().then(computeConfigAndUpdate);
|
|
2250
|
+
return;
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
computeConfigAndUpdate();
|
|
2254
|
+
});
|
|
2255
|
+
ArrayPush$1.call(wiredDisconnecting, () => {
|
|
2256
|
+
connector.disconnect();
|
|
2257
|
+
resetConfigWatcher();
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
function connectWireAdapters(vm) {
|
|
2263
|
+
const {
|
|
2264
|
+
wiredConnecting
|
|
2265
|
+
} = vm.context;
|
|
2266
|
+
for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
|
2267
|
+
wiredConnecting[i]();
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
function disconnectWireAdapters(vm) {
|
|
2271
|
+
const {
|
|
2272
|
+
wiredDisconnecting
|
|
2273
|
+
} = vm.context;
|
|
2274
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2275
|
+
// job
|
|
2276
|
+
for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
|
|
2277
|
+
wiredDisconnecting[i]();
|
|
2278
|
+
}
|
|
2279
|
+
}, noop);
|
|
2036
2280
|
}
|
|
2037
2281
|
|
|
2038
2282
|
/*
|
|
@@ -2041,50 +2285,161 @@ function internalTrackDecorator(key) {
|
|
|
2041
2285
|
* SPDX-License-Identifier: MIT
|
|
2042
2286
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2043
2287
|
*/
|
|
2044
|
-
|
|
2045
|
-
* @wire decorator to wire fields and methods to a wire adapter in
|
|
2046
|
-
* LWC Components. This function implements the internals of this
|
|
2047
|
-
* decorator.
|
|
2048
|
-
*/
|
|
2049
|
-
function wire(_adapter, _config) {
|
|
2288
|
+
function api$1() {
|
|
2050
2289
|
if (process.env.NODE_ENV !== 'production') {
|
|
2051
|
-
assert.fail(
|
|
2290
|
+
assert.fail(`@api decorator can only be used as a decorator function.`);
|
|
2052
2291
|
}
|
|
2053
2292
|
throw new Error();
|
|
2054
2293
|
}
|
|
2055
|
-
function
|
|
2294
|
+
function createPublicPropertyDescriptor(key) {
|
|
2056
2295
|
return {
|
|
2057
2296
|
get() {
|
|
2058
2297
|
const vm = getAssociatedVM(this);
|
|
2298
|
+
if (isBeingConstructed(vm)) {
|
|
2299
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2300
|
+
logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
2301
|
+
}
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2059
2304
|
componentValueObserved(vm, key);
|
|
2060
|
-
return vm.
|
|
2305
|
+
return vm.cmpProps[key];
|
|
2061
2306
|
},
|
|
2062
|
-
set(
|
|
2307
|
+
set(newValue) {
|
|
2063
2308
|
const vm = getAssociatedVM(this);
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2309
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2310
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2311
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2312
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2313
|
+
}
|
|
2314
|
+
vm.cmpProps[key] = newValue;
|
|
2315
|
+
componentValueMutated(vm, key);
|
|
2071
2316
|
},
|
|
2072
2317
|
enumerable: true,
|
|
2073
2318
|
configurable: true,
|
|
2074
2319
|
};
|
|
2075
2320
|
}
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2321
|
+
function createPublicAccessorDescriptor(key, descriptor) {
|
|
2322
|
+
const { get, set, enumerable, configurable } = descriptor;
|
|
2323
|
+
if (!isFunction$1(get)) {
|
|
2324
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2325
|
+
assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
|
|
2326
|
+
}
|
|
2327
|
+
throw new Error();
|
|
2328
|
+
}
|
|
2329
|
+
return {
|
|
2330
|
+
get() {
|
|
2331
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2332
|
+
// Assert that the this value is an actual Component with an associated VM.
|
|
2333
|
+
getAssociatedVM(this);
|
|
2334
|
+
}
|
|
2335
|
+
return get.call(this);
|
|
2336
|
+
},
|
|
2337
|
+
set(newValue) {
|
|
2338
|
+
const vm = getAssociatedVM(this);
|
|
2339
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2340
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2341
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2342
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2343
|
+
}
|
|
2344
|
+
if (set) {
|
|
2345
|
+
set.call(this, newValue);
|
|
2346
|
+
}
|
|
2347
|
+
else if (process.env.NODE_ENV !== 'production') {
|
|
2348
|
+
assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
|
|
2349
|
+
}
|
|
2350
|
+
},
|
|
2351
|
+
enumerable,
|
|
2352
|
+
configurable,
|
|
2353
|
+
};
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
/*
|
|
2357
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2358
|
+
* All rights reserved.
|
|
2359
|
+
* SPDX-License-Identifier: MIT
|
|
2360
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2361
|
+
*/
|
|
2362
|
+
function track(target) {
|
|
2363
|
+
if (arguments.length === 1) {
|
|
2364
|
+
return getReactiveProxy(target);
|
|
2365
|
+
}
|
|
2366
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2367
|
+
assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
|
|
2368
|
+
}
|
|
2369
|
+
throw new Error();
|
|
2370
|
+
}
|
|
2371
|
+
function internalTrackDecorator(key) {
|
|
2372
|
+
return {
|
|
2373
|
+
get() {
|
|
2374
|
+
const vm = getAssociatedVM(this);
|
|
2375
|
+
componentValueObserved(vm, key);
|
|
2376
|
+
return vm.cmpFields[key];
|
|
2377
|
+
},
|
|
2378
|
+
set(newValue) {
|
|
2379
|
+
const vm = getAssociatedVM(this);
|
|
2380
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2381
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2382
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2383
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2384
|
+
}
|
|
2385
|
+
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
2386
|
+
updateComponentValue(vm, key, reactiveOrAnyValue);
|
|
2387
|
+
},
|
|
2388
|
+
enumerable: true,
|
|
2389
|
+
configurable: true,
|
|
2390
|
+
};
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
/*
|
|
2394
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2395
|
+
* All rights reserved.
|
|
2396
|
+
* SPDX-License-Identifier: MIT
|
|
2397
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2398
|
+
*/
|
|
2399
|
+
/**
|
|
2400
|
+
* @wire decorator to wire fields and methods to a wire adapter in
|
|
2401
|
+
* LWC Components. This function implements the internals of this
|
|
2402
|
+
* decorator.
|
|
2403
|
+
*/
|
|
2404
|
+
function wire(_adapter, _config) {
|
|
2405
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2406
|
+
assert.fail('@wire(adapter, config?) may only be used as a decorator.');
|
|
2407
|
+
}
|
|
2408
|
+
throw new Error();
|
|
2409
|
+
}
|
|
2410
|
+
function internalWireFieldDecorator(key) {
|
|
2411
|
+
return {
|
|
2412
|
+
get() {
|
|
2413
|
+
const vm = getAssociatedVM(this);
|
|
2414
|
+
componentValueObserved(vm, key);
|
|
2415
|
+
return vm.cmpFields[key];
|
|
2416
|
+
},
|
|
2417
|
+
set(value) {
|
|
2418
|
+
const vm = getAssociatedVM(this);
|
|
2419
|
+
/**
|
|
2420
|
+
* Reactivity for wired fields is provided in wiring.
|
|
2421
|
+
* We intentionally add reactivity here since this is just
|
|
2422
|
+
* letting the author to do the wrong thing, but it will keep our
|
|
2423
|
+
* system to be backward compatible.
|
|
2424
|
+
*/
|
|
2425
|
+
updateComponentValue(vm, key, value);
|
|
2426
|
+
},
|
|
2427
|
+
enumerable: true,
|
|
2428
|
+
configurable: true,
|
|
2429
|
+
};
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
/*
|
|
2433
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2434
|
+
* All rights reserved.
|
|
2435
|
+
* SPDX-License-Identifier: MIT
|
|
2436
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2437
|
+
*/
|
|
2438
|
+
function getClassDescriptorType(descriptor) {
|
|
2439
|
+
if (isFunction$1(descriptor.value)) {
|
|
2440
|
+
return "method" /* DescriptorType.Method */;
|
|
2441
|
+
}
|
|
2442
|
+
else if (isFunction$1(descriptor.set) || isFunction$1(descriptor.get)) {
|
|
2088
2443
|
return "accessor" /* DescriptorType.Accessor */;
|
|
2089
2444
|
}
|
|
2090
2445
|
else {
|
|
@@ -2299,8 +2654,8 @@ function getDecoratorsMeta(Ctor) {
|
|
|
2299
2654
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2300
2655
|
*/
|
|
2301
2656
|
let warned = false;
|
|
2302
|
-
//
|
|
2303
|
-
if (process.env.NODE_ENV
|
|
2657
|
+
// Only used in LWC's Karma tests
|
|
2658
|
+
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
|
2304
2659
|
// @ts-ignore
|
|
2305
2660
|
window.__lwcResetWarnedOnVersionMismatch = () => {
|
|
2306
2661
|
warned = false;
|
|
@@ -2596,10 +2951,7 @@ function rehydrateHotComponent(Ctor) {
|
|
|
2596
2951
|
return canRefreshAllInstances;
|
|
2597
2952
|
}
|
|
2598
2953
|
function getTemplateOrSwappedTemplate(tpl) {
|
|
2599
|
-
|
|
2600
|
-
// this method should never leak to prod
|
|
2601
|
-
throw new ReferenceError();
|
|
2602
|
-
}
|
|
2954
|
+
assertNotProd(); // this method should never leak to prod
|
|
2603
2955
|
const visited = new Set();
|
|
2604
2956
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
2605
2957
|
visited.add(tpl);
|
|
@@ -2608,10 +2960,7 @@ function getTemplateOrSwappedTemplate(tpl) {
|
|
|
2608
2960
|
return tpl;
|
|
2609
2961
|
}
|
|
2610
2962
|
function getComponentOrSwappedComponent(Ctor) {
|
|
2611
|
-
|
|
2612
|
-
// this method should never leak to prod
|
|
2613
|
-
throw new ReferenceError();
|
|
2614
|
-
}
|
|
2963
|
+
assertNotProd(); // this method should never leak to prod
|
|
2615
2964
|
const visited = new Set();
|
|
2616
2965
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
2617
2966
|
visited.add(Ctor);
|
|
@@ -2620,10 +2969,7 @@ function getComponentOrSwappedComponent(Ctor) {
|
|
|
2620
2969
|
return Ctor;
|
|
2621
2970
|
}
|
|
2622
2971
|
function getStyleOrSwappedStyle(style) {
|
|
2623
|
-
|
|
2624
|
-
// this method should never leak to prod
|
|
2625
|
-
throw new ReferenceError();
|
|
2626
|
-
}
|
|
2972
|
+
assertNotProd(); // this method should never leak to prod
|
|
2627
2973
|
const visited = new Set();
|
|
2628
2974
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
2629
2975
|
visited.add(style);
|
|
@@ -2632,10 +2978,7 @@ function getStyleOrSwappedStyle(style) {
|
|
|
2632
2978
|
return style;
|
|
2633
2979
|
}
|
|
2634
2980
|
function setActiveVM(vm) {
|
|
2635
|
-
|
|
2636
|
-
// this method should never leak to prod
|
|
2637
|
-
throw new ReferenceError();
|
|
2638
|
-
}
|
|
2981
|
+
assertNotProd(); // this method should never leak to prod
|
|
2639
2982
|
// tracking active component
|
|
2640
2983
|
const Ctor = vm.def.ctor;
|
|
2641
2984
|
let componentVMs = activeComponents.get(Ctor);
|
|
@@ -2678,10 +3021,7 @@ function setActiveVM(vm) {
|
|
|
2678
3021
|
}
|
|
2679
3022
|
}
|
|
2680
3023
|
function removeActiveVM(vm) {
|
|
2681
|
-
|
|
2682
|
-
// this method should never leak to prod
|
|
2683
|
-
throw new ReferenceError();
|
|
2684
|
-
}
|
|
3024
|
+
assertNotProd(); // this method should never leak to prod
|
|
2685
3025
|
// tracking inactive component
|
|
2686
3026
|
const Ctor = vm.def.ctor;
|
|
2687
3027
|
let list = activeComponents.get(Ctor);
|
|
@@ -4858,10 +5198,7 @@ function setVMBeingRendered(vm) {
|
|
|
4858
5198
|
vmBeingRendered = vm;
|
|
4859
5199
|
}
|
|
4860
5200
|
function validateSlots(vm, html) {
|
|
4861
|
-
|
|
4862
|
-
// this method should never leak to prod
|
|
4863
|
-
throw new ReferenceError();
|
|
4864
|
-
}
|
|
5201
|
+
assertNotProd(); // this method should never leak to prod
|
|
4865
5202
|
const { cmpSlots } = vm;
|
|
4866
5203
|
const { slots = EmptyArray } = html;
|
|
4867
5204
|
for (const slotName in cmpSlots.slotAssignments) {
|
|
@@ -4995,9 +5332,7 @@ function evaluateTemplate(vm, html) {
|
|
|
4995
5332
|
setActiveVM(vm);
|
|
4996
5333
|
}
|
|
4997
5334
|
// reset the refs; they will be set during the tmpl() instantiation
|
|
4998
|
-
|
|
4999
|
-
vm.hasRefVNodes = hasRefVNodes;
|
|
5000
|
-
vm.refVNodes = hasRefVNodes ? create(null) : null;
|
|
5335
|
+
vm.refVNodes = html.hasRefs ? create(null) : null;
|
|
5001
5336
|
// right before producing the vnodes, we clear up all internal references
|
|
5002
5337
|
// to custom elements from the template.
|
|
5003
5338
|
vm.velements = [];
|
|
@@ -5184,7 +5519,7 @@ function markComponentAsDirty(vm) {
|
|
|
5184
5519
|
const cmpEventListenerMap = new WeakMap();
|
|
5185
5520
|
function getWrappedComponentsListener(vm, listener) {
|
|
5186
5521
|
if (!isFunction$1(listener)) {
|
|
5187
|
-
throw new TypeError(); // avoiding problems with non-valid listeners
|
|
5522
|
+
throw new TypeError('Expected an EventListener but received ' + typeof listener); // avoiding problems with non-valid listeners
|
|
5188
5523
|
}
|
|
5189
5524
|
let wrappedListener = cmpEventListenerMap.get(listener);
|
|
5190
5525
|
if (isUndefined$1(wrappedListener)) {
|
|
@@ -5329,7 +5664,6 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5329
5664
|
mode,
|
|
5330
5665
|
owner,
|
|
5331
5666
|
refVNodes: null,
|
|
5332
|
-
hasRefVNodes: false,
|
|
5333
5667
|
children: EmptyArray,
|
|
5334
5668
|
aChildren: EmptyArray,
|
|
5335
5669
|
velements: EmptyArray,
|
|
@@ -5792,286 +6126,143 @@ function forceRehydration(vm) {
|
|
|
5792
6126
|
* SPDX-License-Identifier: MIT
|
|
5793
6127
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5794
6128
|
*/
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
}
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
6129
|
+
//
|
|
6130
|
+
// The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
|
|
6131
|
+
// These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
|
|
6132
|
+
// When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
|
|
6133
|
+
// See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
|
|
6134
|
+
//
|
|
6135
|
+
// Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
|
|
6136
|
+
const getElementById = globalThis$1[KEY__NATIVE_GET_ELEMENT_BY_ID];
|
|
6137
|
+
const querySelectorAll = globalThis$1[KEY__NATIVE_QUERY_SELECTOR_ALL];
|
|
6138
|
+
function isSyntheticShadowRootInstance(rootNode) {
|
|
6139
|
+
return rootNode !== document && isTrue(rootNode.synthetic);
|
|
6140
|
+
}
|
|
6141
|
+
function reportViolation(source, target, attrName) {
|
|
6142
|
+
// The vm is either for the source, the target, or both. Either one or both must be using synthetic
|
|
6143
|
+
// shadow for a violation to be detected.
|
|
6144
|
+
let vm = getAssociatedVMIfPresent(source.getRootNode().host);
|
|
6145
|
+
if (isUndefined$1(vm)) {
|
|
6146
|
+
vm = getAssociatedVMIfPresent(target.getRootNode().host);
|
|
6147
|
+
}
|
|
6148
|
+
if (isUndefined$1(vm)) {
|
|
6149
|
+
// vm should never be undefined here, but just to be safe, bail out and don't report
|
|
6150
|
+
return;
|
|
6151
|
+
}
|
|
6152
|
+
report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
|
|
6153
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6154
|
+
// Avoid excessively logging to the console in the case of duplicates.
|
|
6155
|
+
logWarnOnce(`Element <${source.tagName.toLowerCase()}> uses attribute "${attrName}" to reference element ` +
|
|
6156
|
+
`<${target.tagName.toLowerCase()}>, which is not in the same shadow root. This will break in native shadow DOM. ` +
|
|
6157
|
+
`For details, see: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates`, vm);
|
|
6158
|
+
}
|
|
5822
6159
|
}
|
|
5823
|
-
function
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
runWithBoundaryProtection(vm, vm.owner, noop, () => {
|
|
5827
|
-
// job
|
|
5828
|
-
method.call(vm.component, value);
|
|
5829
|
-
}, noop);
|
|
5830
|
-
};
|
|
6160
|
+
function parseIdRefAttributeValue(attrValue) {
|
|
6161
|
+
// split on whitespace and skip empty strings after splitting
|
|
6162
|
+
return isString(attrValue) ? ArrayFilter.call(StringSplit.call(attrValue, /\s+/), Boolean) : [];
|
|
5831
6163
|
}
|
|
5832
|
-
function
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
if (hasPendingConfig === false) {
|
|
5837
|
-
hasPendingConfig = true;
|
|
5838
|
-
// collect new config in the micro-task
|
|
5839
|
-
Promise.resolve().then(() => {
|
|
5840
|
-
hasPendingConfig = false;
|
|
5841
|
-
// resetting current reactive params
|
|
5842
|
-
ro.reset();
|
|
5843
|
-
// dispatching a new config due to a change in the configuration
|
|
5844
|
-
computeConfigAndUpdate();
|
|
5845
|
-
});
|
|
6164
|
+
function detectSyntheticCrossRootAria(elm, attrName, attrValue) {
|
|
6165
|
+
const root = elm.getRootNode();
|
|
6166
|
+
if (!isSyntheticShadowRootInstance(root)) {
|
|
6167
|
+
return;
|
|
5846
6168
|
}
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
6169
|
+
if (attrName === 'id') {
|
|
6170
|
+
// elm is the target, find the source
|
|
6171
|
+
if (!isString(attrValue) || attrValue.length === 0) {
|
|
6172
|
+
// if our id is null or empty, nobody can reference us
|
|
6173
|
+
return;
|
|
6174
|
+
}
|
|
6175
|
+
for (const idRefAttrName of ID_REFERENCING_ATTRIBUTES_SET) {
|
|
6176
|
+
// Query all global elements with this attribute. The attribute selector syntax `~=` is for values
|
|
6177
|
+
// that reference multiple IDs, separated by whitespace.
|
|
6178
|
+
const query = `[${idRefAttrName}~="${CSS.escape(attrValue)}"]`;
|
|
6179
|
+
const sourceElements = querySelectorAll.call(document, query);
|
|
6180
|
+
for (let i = 0; i < sourceElements.length; i++) {
|
|
6181
|
+
const sourceElement = sourceElements[i];
|
|
6182
|
+
const sourceRoot = sourceElement.getRootNode();
|
|
6183
|
+
if (sourceRoot !== root) {
|
|
6184
|
+
reportViolation(sourceElement, elm, idRefAttrName);
|
|
6185
|
+
break;
|
|
6186
|
+
}
|
|
6187
|
+
}
|
|
6188
|
+
}
|
|
6189
|
+
}
|
|
6190
|
+
else {
|
|
6191
|
+
// elm is the source, find the target
|
|
6192
|
+
const ids = parseIdRefAttributeValue(attrValue);
|
|
6193
|
+
for (const id of ids) {
|
|
6194
|
+
const target = getElementById.call(document, id);
|
|
6195
|
+
if (!isNull(target)) {
|
|
6196
|
+
const targetRoot = target.getRootNode();
|
|
6197
|
+
if (targetRoot !== root) {
|
|
6198
|
+
// target element's shadow root is not the same as ours
|
|
6199
|
+
reportViolation(elm, target, attrName);
|
|
6200
|
+
}
|
|
6201
|
+
}
|
|
6202
|
+
}
|
|
5878
6203
|
}
|
|
5879
|
-
} = vm;
|
|
5880
|
-
// waiting for the component to be connected to formally request the context via the token
|
|
5881
|
-
ArrayPush$1.call(wiredConnecting, () => {
|
|
5882
|
-
// This event is responsible for connecting the host element with another
|
|
5883
|
-
// element in the composed path that is providing contextual data. The provider
|
|
5884
|
-
// must be listening for a special dom event with the name corresponding to the value of
|
|
5885
|
-
// `adapterContextToken`, which will remain secret and internal to this file only to
|
|
5886
|
-
// guarantee that the linkage can be forged.
|
|
5887
|
-
const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
|
|
5888
|
-
setNewContext(newContext) {
|
|
5889
|
-
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
5890
|
-
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
5891
|
-
callbackWhenContextIsReady(newContext);
|
|
5892
|
-
},
|
|
5893
|
-
setDisconnectedCallback(disconnectCallback) {
|
|
5894
|
-
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
5895
|
-
// the the element hosting the wire is disconnected
|
|
5896
|
-
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
5897
|
-
}
|
|
5898
|
-
});
|
|
5899
|
-
dispatchEvent(elm, contextRegistrationEvent);
|
|
5900
|
-
});
|
|
5901
6204
|
}
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
} = wireDef;
|
|
5909
|
-
let debugInfo;
|
|
5910
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5911
|
-
const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
|
|
5912
|
-
debugInfo = create(null);
|
|
5913
|
-
debugInfo.wasDataProvisionedForConfig = false;
|
|
5914
|
-
vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
|
|
5915
|
-
}
|
|
5916
|
-
const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
5917
|
-
const dataCallback = value => {
|
|
5918
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5919
|
-
debugInfo.data = value;
|
|
5920
|
-
// Note: most of the time, the data provided is for the current config, but there may be
|
|
5921
|
-
// some conditions in which it does not, ex:
|
|
5922
|
-
// race conditions in a poor network while the adapter does not cancel a previous request.
|
|
5923
|
-
debugInfo.wasDataProvisionedForConfig = true;
|
|
6205
|
+
let enabled = false;
|
|
6206
|
+
// We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
|
|
6207
|
+
// reporting is not enabled. It should also only run once
|
|
6208
|
+
function enableDetection() {
|
|
6209
|
+
if (enabled) {
|
|
6210
|
+
return; // don't double-apply the patches
|
|
5924
6211
|
}
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
});
|
|
5936
|
-
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
5937
|
-
// job
|
|
5938
|
-
connector = new adapter(dataCallback);
|
|
5939
|
-
}, noop);
|
|
5940
|
-
const updateConnectorConfig = config => {
|
|
5941
|
-
// every time the config is recomputed due to tracking,
|
|
5942
|
-
// this callback will be invoked with the new computed config
|
|
5943
|
-
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
5944
|
-
// job
|
|
5945
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
5946
|
-
debugInfo.config = config;
|
|
5947
|
-
debugInfo.context = context;
|
|
5948
|
-
debugInfo.wasDataProvisionedForConfig = false;
|
|
5949
|
-
}
|
|
5950
|
-
connector.update(config, context);
|
|
5951
|
-
}, noop);
|
|
5952
|
-
};
|
|
5953
|
-
// Computes the current wire config and calls the update method on the wire adapter.
|
|
5954
|
-
// If it has params, we will need to observe changes in the next tick.
|
|
5955
|
-
const {
|
|
5956
|
-
computeConfigAndUpdate,
|
|
5957
|
-
ro
|
|
5958
|
-
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
5959
|
-
// if the adapter needs contextualization, we need to watch for new context and push it alongside the config
|
|
5960
|
-
if (!isUndefined$1(adapter.contextSchema)) {
|
|
5961
|
-
createContextWatcher(vm, wireDef, newContext => {
|
|
5962
|
-
// every time the context is pushed into this component,
|
|
5963
|
-
// this callback will be invoked with the new computed context
|
|
5964
|
-
if (context !== newContext) {
|
|
5965
|
-
context = newContext;
|
|
5966
|
-
// Note: when new context arrives, the config will be recomputed and pushed along side the new
|
|
5967
|
-
// context, this is to preserve the identity characteristics, config should not have identity
|
|
5968
|
-
// (ever), while context can have identity
|
|
5969
|
-
if (vm.state === 1 /* VMState.connected */) {
|
|
5970
|
-
computeConfigAndUpdate();
|
|
5971
|
-
}
|
|
5972
|
-
}
|
|
6212
|
+
enabled = true;
|
|
6213
|
+
const { setAttribute } = Element.prototype;
|
|
6214
|
+
// Detect calling `setAttribute` to set an idref or an id
|
|
6215
|
+
assign(Element.prototype, {
|
|
6216
|
+
setAttribute(attrName, attrValue) {
|
|
6217
|
+
setAttribute.call(this, attrName, attrValue);
|
|
6218
|
+
if (attrName === 'id' || ID_REFERENCING_ATTRIBUTES_SET.has(attrName)) {
|
|
6219
|
+
detectSyntheticCrossRootAria(this, attrName, attrValue);
|
|
6220
|
+
}
|
|
6221
|
+
},
|
|
5973
6222
|
});
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
6223
|
+
// Detect `elm.id = 'foo'`
|
|
6224
|
+
const idDescriptor = getOwnPropertyDescriptor$1(Element.prototype, 'id');
|
|
6225
|
+
if (!isUndefined$1(idDescriptor)) {
|
|
6226
|
+
const { get, set } = idDescriptor;
|
|
6227
|
+
// These should always be a getter and a setter, but if someone is monkeying with the global descriptor, ignore it
|
|
6228
|
+
if (isFunction$1(get) && isFunction$1(set)) {
|
|
6229
|
+
defineProperty(Element.prototype, 'id', {
|
|
6230
|
+
get() {
|
|
6231
|
+
return get.call(this);
|
|
6232
|
+
},
|
|
6233
|
+
set(value) {
|
|
6234
|
+
set.call(this, value);
|
|
6235
|
+
detectSyntheticCrossRootAria(this, 'id', value);
|
|
6236
|
+
},
|
|
6237
|
+
// On the default descriptor for 'id', enumerable and configurable are true
|
|
6238
|
+
enumerable: true,
|
|
6239
|
+
configurable: true,
|
|
6240
|
+
});
|
|
6241
|
+
}
|
|
6242
|
+
}
|
|
5981
6243
|
}
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
6244
|
+
// Our detection logic relies on some modern browser features. We can just skip reporting the data
|
|
6245
|
+
// for unsupported browsers
|
|
6246
|
+
function supportsCssEscape() {
|
|
6247
|
+
return typeof CSS !== 'undefined' && isFunction$1(CSS.escape);
|
|
5985
6248
|
}
|
|
5986
|
-
|
|
5987
|
-
|
|
6249
|
+
// If this page is not using synthetic shadow, then we don't need to install detection. Note
|
|
6250
|
+
// that we are assuming synthetic shadow is loaded before LWC.
|
|
6251
|
+
function isSyntheticShadowLoaded() {
|
|
6252
|
+
// We should probably be calling `renderer.isSyntheticShadowDefined`, but 1) we don't have access to the renderer,
|
|
6253
|
+
// and 2) this code needs to run in @lwc/engine-core, so it can access `logWarn()` and `report()`.
|
|
6254
|
+
return hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
|
|
5988
6255
|
}
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
adapter = adapter.adapter;
|
|
5993
|
-
}
|
|
5994
|
-
const method = descriptor.value;
|
|
5995
|
-
const def = {
|
|
5996
|
-
adapter,
|
|
5997
|
-
method,
|
|
5998
|
-
configCallback,
|
|
5999
|
-
dynamic
|
|
6000
|
-
};
|
|
6001
|
-
WireMetaMap.set(descriptor, def);
|
|
6002
|
-
}
|
|
6003
|
-
function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
|
|
6004
|
-
// support for callable adapters
|
|
6005
|
-
if (adapter.adapter) {
|
|
6006
|
-
adapter = adapter.adapter;
|
|
6007
|
-
}
|
|
6008
|
-
const def = {
|
|
6009
|
-
adapter,
|
|
6010
|
-
configCallback,
|
|
6011
|
-
dynamic
|
|
6012
|
-
};
|
|
6013
|
-
WireMetaMap.set(descriptor, def);
|
|
6014
|
-
}
|
|
6015
|
-
function installWireAdapters(vm) {
|
|
6016
|
-
const {
|
|
6017
|
-
context,
|
|
6018
|
-
def: {
|
|
6019
|
-
wire
|
|
6020
|
-
}
|
|
6021
|
-
} = vm;
|
|
6022
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6023
|
-
vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
|
|
6024
|
-
}
|
|
6025
|
-
const wiredConnecting = context.wiredConnecting = [];
|
|
6026
|
-
const wiredDisconnecting = context.wiredDisconnecting = [];
|
|
6027
|
-
for (const fieldNameOrMethod in wire) {
|
|
6028
|
-
const descriptor = wire[fieldNameOrMethod];
|
|
6029
|
-
const wireDef = WireMetaMap.get(descriptor);
|
|
6256
|
+
// Detecting cross-root ARIA in synthetic shadow only makes sense for the browser
|
|
6257
|
+
if (process.env.IS_BROWSER && supportsCssEscape() && isSyntheticShadowLoaded()) {
|
|
6258
|
+
// Always run detection in dev mode, so we can at least print to the console
|
|
6030
6259
|
if (process.env.NODE_ENV !== 'production') {
|
|
6031
|
-
|
|
6260
|
+
enableDetection();
|
|
6032
6261
|
}
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
computeConfigAndUpdate,
|
|
6037
|
-
resetConfigWatcher
|
|
6038
|
-
} = createConnector(vm, fieldNameOrMethod, wireDef);
|
|
6039
|
-
const hasDynamicParams = wireDef.dynamic.length > 0;
|
|
6040
|
-
ArrayPush$1.call(wiredConnecting, () => {
|
|
6041
|
-
connector.connect();
|
|
6042
|
-
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
6043
|
-
if (hasDynamicParams) {
|
|
6044
|
-
Promise.resolve().then(computeConfigAndUpdate);
|
|
6045
|
-
return;
|
|
6046
|
-
}
|
|
6047
|
-
}
|
|
6048
|
-
computeConfigAndUpdate();
|
|
6049
|
-
});
|
|
6050
|
-
ArrayPush$1.call(wiredDisconnecting, () => {
|
|
6051
|
-
connector.disconnect();
|
|
6052
|
-
resetConfigWatcher();
|
|
6053
|
-
});
|
|
6054
|
-
}
|
|
6055
|
-
}
|
|
6056
|
-
}
|
|
6057
|
-
function connectWireAdapters(vm) {
|
|
6058
|
-
const {
|
|
6059
|
-
wiredConnecting
|
|
6060
|
-
} = vm.context;
|
|
6061
|
-
for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
|
6062
|
-
wiredConnecting[i]();
|
|
6063
|
-
}
|
|
6064
|
-
}
|
|
6065
|
-
function disconnectWireAdapters(vm) {
|
|
6066
|
-
const {
|
|
6067
|
-
wiredDisconnecting
|
|
6068
|
-
} = vm.context;
|
|
6069
|
-
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
6070
|
-
// job
|
|
6071
|
-
for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
|
|
6072
|
-
wiredDisconnecting[i]();
|
|
6262
|
+
else {
|
|
6263
|
+
// In prod mode, only enable detection if reporting is enabled
|
|
6264
|
+
onReportingEnabled(enableDetection);
|
|
6073
6265
|
}
|
|
6074
|
-
}, noop);
|
|
6075
6266
|
}
|
|
6076
6267
|
|
|
6077
6268
|
/*
|
|
@@ -6744,5 +6935,5 @@ function getComponentConstructor(elm) {
|
|
|
6744
6935
|
return ctor;
|
|
6745
6936
|
}
|
|
6746
6937
|
|
|
6747
|
-
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6748
|
-
/* version: 2.
|
|
6938
|
+
export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6939
|
+
/* version: 2.35.1 */
|