@lwc/engine-core 2.34.0 → 2.35.0
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 +720 -485
- package/dist/engine-core.js +721 -487
- package/package.json +4 -4
- package/types/framework/main.d.ts +1 -0
- package/types/framework/reporting.d.ts +31 -0
- 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, freeze, assert, 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
|
/*
|
|
@@ -33,94 +33,167 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
|
33
33
|
* SPDX-License-Identifier: MIT
|
|
34
34
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
35
35
|
*/
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
/** Callbacks to invoke when reporting is enabled **/
|
|
37
|
+
const onReportingEnabledCallbacks = [];
|
|
38
|
+
/** The currently assigned reporting dispatcher. */
|
|
39
|
+
let currentDispatcher$1 = noop;
|
|
40
|
+
/**
|
|
41
|
+
* Whether reporting is enabled.
|
|
42
|
+
*
|
|
43
|
+
* Note that this may seem redundant, given you can just check if the currentDispatcher is undefined,
|
|
44
|
+
* but it turns out that Terser only strips out unused code if we use this explicit boolean.
|
|
45
|
+
*/
|
|
46
|
+
let enabled$1 = false;
|
|
47
|
+
const reportingControl = {
|
|
48
|
+
/**
|
|
49
|
+
* Attach a new reporting control (aka dispatcher).
|
|
50
|
+
*
|
|
51
|
+
* @param dispatcher - reporting control
|
|
52
|
+
*/
|
|
53
|
+
attachDispatcher(dispatcher) {
|
|
54
|
+
enabled$1 = true;
|
|
55
|
+
currentDispatcher$1 = dispatcher;
|
|
56
|
+
for (const callback of onReportingEnabledCallbacks) {
|
|
57
|
+
try {
|
|
58
|
+
callback();
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
// This should never happen. But if it does, we don't want one callback to cause another to fail
|
|
62
|
+
// eslint-disable-next-line no-console
|
|
63
|
+
console.error('Could not invoke callback', err);
|
|
64
|
+
}
|
|
44
65
|
}
|
|
66
|
+
onReportingEnabledCallbacks.length = 0; // clear the array
|
|
67
|
+
},
|
|
68
|
+
/**
|
|
69
|
+
* Detach the current reporting control (aka dispatcher).
|
|
70
|
+
*/
|
|
71
|
+
detachDispatcher() {
|
|
72
|
+
enabled$1 = false;
|
|
73
|
+
currentDispatcher$1 = noop;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Call a callback when reporting is enabled, or immediately if reporting is already enabled.
|
|
78
|
+
* Will only ever be called once.
|
|
79
|
+
* @param callback
|
|
80
|
+
*/
|
|
81
|
+
function onReportingEnabled(callback) {
|
|
82
|
+
if (enabled$1) {
|
|
83
|
+
// call immediately
|
|
84
|
+
callback();
|
|
45
85
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
callbacks[i]();
|
|
86
|
+
else {
|
|
87
|
+
// call later
|
|
88
|
+
onReportingEnabledCallbacks.push(callback);
|
|
50
89
|
}
|
|
51
90
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Report to the current dispatcher, if there is one.
|
|
93
|
+
* @param reportingEventId
|
|
94
|
+
* @param vm
|
|
95
|
+
*/
|
|
96
|
+
function report(reportingEventId, vm) {
|
|
97
|
+
if (enabled$1) {
|
|
98
|
+
currentDispatcher$1(reportingEventId, vm.tagName, vm.idx);
|
|
60
99
|
}
|
|
61
|
-
ArrayPush$1.call(nextTickCallbackQueue, callback);
|
|
62
100
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
104
|
+
* All rights reserved.
|
|
105
|
+
* SPDX-License-Identifier: MIT
|
|
106
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
107
|
+
*/
|
|
108
|
+
function getComponentTag(vm) {
|
|
109
|
+
return `<${StringToLowerCase.call(vm.tagName)}>`;
|
|
110
|
+
}
|
|
111
|
+
// TODO [#1695]: Unify getComponentStack and getErrorComponentStack
|
|
112
|
+
function getComponentStack(vm) {
|
|
113
|
+
const stack = [];
|
|
114
|
+
let prefix = '';
|
|
115
|
+
while (!isNull(vm.owner)) {
|
|
116
|
+
ArrayPush$1.call(stack, prefix + getComponentTag(vm));
|
|
117
|
+
vm = vm.owner;
|
|
118
|
+
prefix += '\t';
|
|
68
119
|
}
|
|
69
|
-
return
|
|
120
|
+
return ArrayJoin.call(stack, '\n');
|
|
70
121
|
}
|
|
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
|
-
}
|
|
122
|
+
function getErrorComponentStack(vm) {
|
|
123
|
+
const wcStack = [];
|
|
124
|
+
let currentVm = vm;
|
|
125
|
+
while (!isNull(currentVm)) {
|
|
126
|
+
ArrayPush$1.call(wcStack, getComponentTag(currentVm));
|
|
127
|
+
currentVm = currentVm.owner;
|
|
85
128
|
}
|
|
86
|
-
return
|
|
129
|
+
return wcStack.reverse().join('\n\t');
|
|
87
130
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
131
|
+
|
|
132
|
+
/*
|
|
133
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
134
|
+
* All rights reserved.
|
|
135
|
+
* SPDX-License-Identifier: MIT
|
|
136
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
137
|
+
*/
|
|
138
|
+
function addErrorComponentStack(vm, error) {
|
|
139
|
+
if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
|
|
140
|
+
const wcStack = getErrorComponentStack(vm);
|
|
141
|
+
defineProperty(error, 'wcStack', {
|
|
142
|
+
get() {
|
|
143
|
+
return wcStack;
|
|
144
|
+
},
|
|
145
|
+
});
|
|
95
146
|
}
|
|
96
|
-
return result;
|
|
97
147
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
148
|
+
|
|
149
|
+
/*
|
|
150
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
151
|
+
* All rights reserved.
|
|
152
|
+
* SPDX-License-Identifier: MIT
|
|
153
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
154
|
+
*/
|
|
155
|
+
const alreadyLoggedMessages = new Set();
|
|
156
|
+
// @ts-ignore
|
|
157
|
+
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
window.__lwcResetAlreadyLoggedMessages = () => {
|
|
160
|
+
alreadyLoggedMessages.clear();
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function log(method, message, vm, once) {
|
|
164
|
+
let msg = `[LWC ${method}]: ${message}`;
|
|
165
|
+
if (!isUndefined$1(vm)) {
|
|
166
|
+
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
167
|
+
}
|
|
168
|
+
if (once) {
|
|
169
|
+
if (alreadyLoggedMessages.has(msg)) {
|
|
170
|
+
return;
|
|
106
171
|
}
|
|
172
|
+
alreadyLoggedMessages.add(msg);
|
|
107
173
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
throw new Error('refVNodes must be defined when setting a ref');
|
|
174
|
+
// In Jest tests, reduce the warning and error verbosity by not printing the callstack
|
|
175
|
+
if (process.env.NODE_ENV === 'test') {
|
|
176
|
+
/* eslint-disable-next-line no-console */
|
|
177
|
+
console[method](msg);
|
|
178
|
+
return;
|
|
114
179
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
refVNodes[ref] = vnode;
|
|
180
|
+
try {
|
|
181
|
+
throw new Error(msg);
|
|
182
|
+
}
|
|
183
|
+
catch (e) {
|
|
184
|
+
/* eslint-disable-next-line no-console */
|
|
185
|
+
console[method](e);
|
|
122
186
|
}
|
|
123
187
|
}
|
|
188
|
+
function logError(message, vm) {
|
|
189
|
+
log('error', message, vm, false);
|
|
190
|
+
}
|
|
191
|
+
function logWarn(message, vm) {
|
|
192
|
+
log('warn', message, vm, false);
|
|
193
|
+
}
|
|
194
|
+
function logWarnOnce(message, vm) {
|
|
195
|
+
log('warn', message, vm, true);
|
|
196
|
+
}
|
|
124
197
|
|
|
125
198
|
/*
|
|
126
199
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
@@ -256,80 +329,96 @@ function createReactiveObserver(callback) {
|
|
|
256
329
|
* SPDX-License-Identifier: MIT
|
|
257
330
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
258
331
|
*/
|
|
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;
|
|
332
|
+
let nextTickCallbackQueue = [];
|
|
333
|
+
const SPACE_CHAR = 32;
|
|
334
|
+
const EmptyObject = seal(create(null));
|
|
335
|
+
const EmptyArray = seal([]);
|
|
336
|
+
function flushCallbackQueue() {
|
|
337
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
338
|
+
if (nextTickCallbackQueue.length === 0) {
|
|
339
|
+
throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
|
|
340
|
+
}
|
|
279
341
|
}
|
|
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
|
-
});
|
|
342
|
+
const callbacks = nextTickCallbackQueue;
|
|
343
|
+
nextTickCallbackQueue = []; // reset to a new queue
|
|
344
|
+
for (let i = 0, len = callbacks.length; i < len; i += 1) {
|
|
345
|
+
callbacks[i]();
|
|
297
346
|
}
|
|
298
347
|
}
|
|
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);
|
|
348
|
+
function addCallbackToNextTick(callback) {
|
|
349
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
350
|
+
if (!isFunction$1(callback)) {
|
|
351
|
+
throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
|
|
352
|
+
}
|
|
319
353
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
console[method](e);
|
|
354
|
+
if (nextTickCallbackQueue.length === 0) {
|
|
355
|
+
Promise.resolve().then(flushCallbackQueue);
|
|
323
356
|
}
|
|
357
|
+
ArrayPush$1.call(nextTickCallbackQueue, callback);
|
|
324
358
|
}
|
|
325
|
-
function
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
359
|
+
function guid() {
|
|
360
|
+
function s4() {
|
|
361
|
+
return Math.floor((1 + Math.random()) * 0x10000)
|
|
362
|
+
.toString(16)
|
|
363
|
+
.substring(1);
|
|
364
|
+
}
|
|
365
|
+
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
330
366
|
}
|
|
331
|
-
|
|
332
|
-
|
|
367
|
+
// Borrowed from Vue template compiler.
|
|
368
|
+
// https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
|
|
369
|
+
const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
|
|
370
|
+
const PROPERTY_DELIMITER = /:(.+)/;
|
|
371
|
+
function parseStyleText(cssText) {
|
|
372
|
+
const styleMap = {};
|
|
373
|
+
const declarations = cssText.split(DECLARATION_DELIMITER);
|
|
374
|
+
for (const declaration of declarations) {
|
|
375
|
+
if (declaration) {
|
|
376
|
+
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
|
377
|
+
if (prop !== undefined && value !== undefined) {
|
|
378
|
+
styleMap[prop.trim()] = value.trim();
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return styleMap;
|
|
383
|
+
}
|
|
384
|
+
// Make a shallow copy of an object but omit the given key
|
|
385
|
+
function cloneAndOmitKey(object, keyToOmit) {
|
|
386
|
+
const result = {};
|
|
387
|
+
for (const key of Object.keys(object)) {
|
|
388
|
+
if (key !== keyToOmit) {
|
|
389
|
+
result[key] = object[key];
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return result;
|
|
393
|
+
}
|
|
394
|
+
function flattenStylesheets(stylesheets) {
|
|
395
|
+
const list = [];
|
|
396
|
+
for (const stylesheet of stylesheets) {
|
|
397
|
+
if (!Array.isArray(stylesheet)) {
|
|
398
|
+
list.push(stylesheet);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
list.push(...flattenStylesheets(stylesheet));
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return list;
|
|
405
|
+
}
|
|
406
|
+
// Set a ref (lwc:ref) on a VM, from a template API
|
|
407
|
+
function setRefVNode(vm, ref, vnode) {
|
|
408
|
+
if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
|
|
409
|
+
throw new Error('refVNodes must be defined when setting a ref');
|
|
410
|
+
}
|
|
411
|
+
// If this method is called, then vm.refVNodes is set as the template has refs.
|
|
412
|
+
// If not, then something went wrong and we threw an error above.
|
|
413
|
+
const refVNodes = vm.refVNodes;
|
|
414
|
+
// In cases of conflict (two elements with the same ref), prefer, the last one,
|
|
415
|
+
// in depth-first traversal order.
|
|
416
|
+
if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
|
|
417
|
+
refVNodes[ref] = vnode;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/*
|
|
333
422
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
334
423
|
* All rights reserved.
|
|
335
424
|
* SPDX-License-Identifier: MIT
|
|
@@ -381,7 +470,7 @@ function offsetPropertyErrorMessage(name) {
|
|
|
381
470
|
//
|
|
382
471
|
// If you update this list, check for test files that recapitulate the same list. Searching the codebase
|
|
383
472
|
// for e.g. "dropzone" should suffice.
|
|
384
|
-
const globalHTMLProperties =
|
|
473
|
+
const globalHTMLProperties = {
|
|
385
474
|
accessKey: {
|
|
386
475
|
attribute: 'accesskey',
|
|
387
476
|
},
|
|
@@ -466,7 +555,7 @@ const globalHTMLProperties = assign(create(null), {
|
|
|
466
555
|
role: {
|
|
467
556
|
attribute: 'role',
|
|
468
557
|
},
|
|
469
|
-
}
|
|
558
|
+
};
|
|
470
559
|
let controlledElement = null;
|
|
471
560
|
let controlledAttributeName;
|
|
472
561
|
function isAttributeLocked(elm, attrName) {
|
|
@@ -1930,91 +2019,379 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
1930
2019
|
* SPDX-License-Identifier: MIT
|
|
1931
2020
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1932
2021
|
*/
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
2022
|
+
const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
|
|
2023
|
+
const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
|
2024
|
+
const WIRE_DEBUG_ENTRY = '@wire';
|
|
2025
|
+
const WireMetaMap = new Map();
|
|
2026
|
+
class WireContextRegistrationEvent extends CustomEvent {
|
|
2027
|
+
constructor(adapterToken, {
|
|
2028
|
+
setNewContext,
|
|
2029
|
+
setDisconnectedCallback
|
|
2030
|
+
}) {
|
|
2031
|
+
super(adapterToken, {
|
|
2032
|
+
bubbles: true,
|
|
2033
|
+
composed: true
|
|
2034
|
+
});
|
|
2035
|
+
defineProperties(this, {
|
|
2036
|
+
setNewContext: {
|
|
2037
|
+
value: setNewContext
|
|
2038
|
+
},
|
|
2039
|
+
setDisconnectedCallback: {
|
|
2040
|
+
value: setDisconnectedCallback
|
|
2041
|
+
}
|
|
2042
|
+
});
|
|
2043
|
+
}
|
|
1938
2044
|
}
|
|
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
|
-
};
|
|
2045
|
+
function createFieldDataCallback(vm, name) {
|
|
2046
|
+
return value => {
|
|
2047
|
+
updateComponentValue(vm, name, value);
|
|
2048
|
+
};
|
|
1965
2049
|
}
|
|
1966
|
-
function
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
2050
|
+
function createMethodDataCallback(vm, method) {
|
|
2051
|
+
return value => {
|
|
2052
|
+
// dispatching new value into the wired method
|
|
2053
|
+
runWithBoundaryProtection(vm, vm.owner, noop, () => {
|
|
2054
|
+
// job
|
|
2055
|
+
method.call(vm.component, value);
|
|
2056
|
+
}, noop);
|
|
2057
|
+
};
|
|
2058
|
+
}
|
|
2059
|
+
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
2060
|
+
let hasPendingConfig = false;
|
|
2061
|
+
// creating the reactive observer for reactive params when needed
|
|
2062
|
+
const ro = createReactiveObserver(() => {
|
|
2063
|
+
if (hasPendingConfig === false) {
|
|
2064
|
+
hasPendingConfig = true;
|
|
2065
|
+
// collect new config in the micro-task
|
|
2066
|
+
Promise.resolve().then(() => {
|
|
2067
|
+
hasPendingConfig = false;
|
|
2068
|
+
// resetting current reactive params
|
|
2069
|
+
ro.reset();
|
|
2070
|
+
// dispatching a new config due to a change in the configuration
|
|
2071
|
+
computeConfigAndUpdate();
|
|
2072
|
+
});
|
|
1973
2073
|
}
|
|
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
|
-
};
|
|
2074
|
+
});
|
|
2075
|
+
const computeConfigAndUpdate = () => {
|
|
2076
|
+
let config;
|
|
2077
|
+
ro.observe(() => config = configCallback(component));
|
|
2078
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
2079
|
+
// TODO: dev-mode validation of config based on the adapter.configSchema
|
|
2080
|
+
// @ts-ignore it is assigned in the observe() callback
|
|
2081
|
+
callbackWhenConfigIsReady(config);
|
|
2082
|
+
};
|
|
2083
|
+
return {
|
|
2084
|
+
computeConfigAndUpdate,
|
|
2085
|
+
ro
|
|
2086
|
+
};
|
|
1999
2087
|
}
|
|
2088
|
+
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
2089
|
+
const {
|
|
2090
|
+
adapter
|
|
2091
|
+
} = wireDef;
|
|
2092
|
+
const adapterContextToken = getAdapterToken(adapter);
|
|
2093
|
+
if (isUndefined$1(adapterContextToken)) {
|
|
2094
|
+
return; // no provider found, nothing to be done
|
|
2095
|
+
}
|
|
2000
2096
|
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
return getReactiveProxy(target);
|
|
2097
|
+
const {
|
|
2098
|
+
elm,
|
|
2099
|
+
context: {
|
|
2100
|
+
wiredConnecting,
|
|
2101
|
+
wiredDisconnecting
|
|
2102
|
+
},
|
|
2103
|
+
renderer: {
|
|
2104
|
+
dispatchEvent
|
|
2010
2105
|
}
|
|
2106
|
+
} = vm;
|
|
2107
|
+
// waiting for the component to be connected to formally request the context via the token
|
|
2108
|
+
ArrayPush$1.call(wiredConnecting, () => {
|
|
2109
|
+
// This event is responsible for connecting the host element with another
|
|
2110
|
+
// element in the composed path that is providing contextual data. The provider
|
|
2111
|
+
// must be listening for a special dom event with the name corresponding to the value of
|
|
2112
|
+
// `adapterContextToken`, which will remain secret and internal to this file only to
|
|
2113
|
+
// guarantee that the linkage can be forged.
|
|
2114
|
+
const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
|
|
2115
|
+
setNewContext(newContext) {
|
|
2116
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
2117
|
+
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
2118
|
+
callbackWhenContextIsReady(newContext);
|
|
2119
|
+
},
|
|
2120
|
+
setDisconnectedCallback(disconnectCallback) {
|
|
2121
|
+
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
2122
|
+
// the the element hosting the wire is disconnected
|
|
2123
|
+
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
2124
|
+
}
|
|
2125
|
+
});
|
|
2126
|
+
dispatchEvent(elm, contextRegistrationEvent);
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
function createConnector(vm, name, wireDef) {
|
|
2130
|
+
const {
|
|
2131
|
+
method,
|
|
2132
|
+
adapter,
|
|
2133
|
+
configCallback,
|
|
2134
|
+
dynamic
|
|
2135
|
+
} = wireDef;
|
|
2136
|
+
let debugInfo;
|
|
2137
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2138
|
+
const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
|
|
2139
|
+
debugInfo = create(null);
|
|
2140
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
2141
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
|
|
2142
|
+
}
|
|
2143
|
+
const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
2144
|
+
const dataCallback = value => {
|
|
2011
2145
|
if (process.env.NODE_ENV !== 'production') {
|
|
2012
|
-
|
|
2146
|
+
debugInfo.data = value;
|
|
2147
|
+
// Note: most of the time, the data provided is for the current config, but there may be
|
|
2148
|
+
// some conditions in which it does not, ex:
|
|
2149
|
+
// race conditions in a poor network while the adapter does not cancel a previous request.
|
|
2150
|
+
debugInfo.wasDataProvisionedForConfig = true;
|
|
2013
2151
|
}
|
|
2014
|
-
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
|
|
2152
|
+
fieldOrMethodCallback(value);
|
|
2153
|
+
};
|
|
2154
|
+
let context;
|
|
2155
|
+
let connector;
|
|
2156
|
+
// Workaround to pass the component element associated to this wire adapter instance.
|
|
2157
|
+
defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
2158
|
+
value: vm.elm
|
|
2159
|
+
});
|
|
2160
|
+
defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
|
|
2161
|
+
value: dynamic
|
|
2162
|
+
});
|
|
2163
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2164
|
+
// job
|
|
2165
|
+
connector = new adapter(dataCallback);
|
|
2166
|
+
}, noop);
|
|
2167
|
+
const updateConnectorConfig = config => {
|
|
2168
|
+
// every time the config is recomputed due to tracking,
|
|
2169
|
+
// this callback will be invoked with the new computed config
|
|
2170
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2171
|
+
// job
|
|
2172
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2173
|
+
debugInfo.config = config;
|
|
2174
|
+
debugInfo.context = context;
|
|
2175
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
2176
|
+
}
|
|
2177
|
+
connector.update(config, context);
|
|
2178
|
+
}, noop);
|
|
2179
|
+
};
|
|
2180
|
+
// Computes the current wire config and calls the update method on the wire adapter.
|
|
2181
|
+
// If it has params, we will need to observe changes in the next tick.
|
|
2182
|
+
const {
|
|
2183
|
+
computeConfigAndUpdate,
|
|
2184
|
+
ro
|
|
2185
|
+
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
2186
|
+
// if the adapter needs contextualization, we need to watch for new context and push it alongside the config
|
|
2187
|
+
if (!isUndefined$1(adapter.contextSchema)) {
|
|
2188
|
+
createContextWatcher(vm, wireDef, newContext => {
|
|
2189
|
+
// every time the context is pushed into this component,
|
|
2190
|
+
// this callback will be invoked with the new computed context
|
|
2191
|
+
if (context !== newContext) {
|
|
2192
|
+
context = newContext;
|
|
2193
|
+
// Note: when new context arrives, the config will be recomputed and pushed along side the new
|
|
2194
|
+
// context, this is to preserve the identity characteristics, config should not have identity
|
|
2195
|
+
// (ever), while context can have identity
|
|
2196
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
2197
|
+
computeConfigAndUpdate();
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
return {
|
|
2203
|
+
// @ts-ignore the boundary protection executes sync, connector is always defined
|
|
2204
|
+
connector,
|
|
2205
|
+
computeConfigAndUpdate,
|
|
2206
|
+
resetConfigWatcher: () => ro.reset()
|
|
2207
|
+
};
|
|
2208
|
+
}
|
|
2209
|
+
const AdapterToTokenMap = new Map();
|
|
2210
|
+
function getAdapterToken(adapter) {
|
|
2211
|
+
return AdapterToTokenMap.get(adapter);
|
|
2212
|
+
}
|
|
2213
|
+
function setAdapterToken(adapter, token) {
|
|
2214
|
+
AdapterToTokenMap.set(adapter, token);
|
|
2215
|
+
}
|
|
2216
|
+
function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2217
|
+
// support for callable adapters
|
|
2218
|
+
if (adapter.adapter) {
|
|
2219
|
+
adapter = adapter.adapter;
|
|
2220
|
+
}
|
|
2221
|
+
const method = descriptor.value;
|
|
2222
|
+
const def = {
|
|
2223
|
+
adapter,
|
|
2224
|
+
method,
|
|
2225
|
+
configCallback,
|
|
2226
|
+
dynamic
|
|
2227
|
+
};
|
|
2228
|
+
WireMetaMap.set(descriptor, def);
|
|
2229
|
+
}
|
|
2230
|
+
function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2231
|
+
// support for callable adapters
|
|
2232
|
+
if (adapter.adapter) {
|
|
2233
|
+
adapter = adapter.adapter;
|
|
2234
|
+
}
|
|
2235
|
+
const def = {
|
|
2236
|
+
adapter,
|
|
2237
|
+
configCallback,
|
|
2238
|
+
dynamic
|
|
2239
|
+
};
|
|
2240
|
+
WireMetaMap.set(descriptor, def);
|
|
2241
|
+
}
|
|
2242
|
+
function installWireAdapters(vm) {
|
|
2243
|
+
const {
|
|
2244
|
+
context,
|
|
2245
|
+
def: {
|
|
2246
|
+
wire
|
|
2247
|
+
}
|
|
2248
|
+
} = vm;
|
|
2249
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2250
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
|
|
2251
|
+
}
|
|
2252
|
+
const wiredConnecting = context.wiredConnecting = [];
|
|
2253
|
+
const wiredDisconnecting = context.wiredDisconnecting = [];
|
|
2254
|
+
for (const fieldNameOrMethod in wire) {
|
|
2255
|
+
const descriptor = wire[fieldNameOrMethod];
|
|
2256
|
+
const wireDef = WireMetaMap.get(descriptor);
|
|
2257
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2258
|
+
assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
|
|
2259
|
+
}
|
|
2260
|
+
if (!isUndefined$1(wireDef)) {
|
|
2261
|
+
const {
|
|
2262
|
+
connector,
|
|
2263
|
+
computeConfigAndUpdate,
|
|
2264
|
+
resetConfigWatcher
|
|
2265
|
+
} = createConnector(vm, fieldNameOrMethod, wireDef);
|
|
2266
|
+
const hasDynamicParams = wireDef.dynamic.length > 0;
|
|
2267
|
+
ArrayPush$1.call(wiredConnecting, () => {
|
|
2268
|
+
connector.connect();
|
|
2269
|
+
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
2270
|
+
if (hasDynamicParams) {
|
|
2271
|
+
Promise.resolve().then(computeConfigAndUpdate);
|
|
2272
|
+
return;
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
computeConfigAndUpdate();
|
|
2276
|
+
});
|
|
2277
|
+
ArrayPush$1.call(wiredDisconnecting, () => {
|
|
2278
|
+
connector.disconnect();
|
|
2279
|
+
resetConfigWatcher();
|
|
2280
|
+
});
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
function connectWireAdapters(vm) {
|
|
2285
|
+
const {
|
|
2286
|
+
wiredConnecting
|
|
2287
|
+
} = vm.context;
|
|
2288
|
+
for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
|
2289
|
+
wiredConnecting[i]();
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
function disconnectWireAdapters(vm) {
|
|
2293
|
+
const {
|
|
2294
|
+
wiredDisconnecting
|
|
2295
|
+
} = vm.context;
|
|
2296
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2297
|
+
// job
|
|
2298
|
+
for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
|
|
2299
|
+
wiredDisconnecting[i]();
|
|
2300
|
+
}
|
|
2301
|
+
}, noop);
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
/*
|
|
2305
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2306
|
+
* All rights reserved.
|
|
2307
|
+
* SPDX-License-Identifier: MIT
|
|
2308
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2309
|
+
*/
|
|
2310
|
+
function api$1() {
|
|
2311
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2312
|
+
assert.fail(`@api decorator can only be used as a decorator function.`);
|
|
2313
|
+
}
|
|
2314
|
+
throw new Error();
|
|
2315
|
+
}
|
|
2316
|
+
function createPublicPropertyDescriptor(key) {
|
|
2317
|
+
return {
|
|
2318
|
+
get() {
|
|
2319
|
+
const vm = getAssociatedVM(this);
|
|
2320
|
+
if (isBeingConstructed(vm)) {
|
|
2321
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2322
|
+
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);
|
|
2323
|
+
}
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
componentValueObserved(vm, key);
|
|
2327
|
+
return vm.cmpProps[key];
|
|
2328
|
+
},
|
|
2329
|
+
set(newValue) {
|
|
2330
|
+
const vm = getAssociatedVM(this);
|
|
2331
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2332
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2333
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2334
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2335
|
+
}
|
|
2336
|
+
vm.cmpProps[key] = newValue;
|
|
2337
|
+
componentValueMutated(vm, key);
|
|
2338
|
+
},
|
|
2339
|
+
enumerable: true,
|
|
2340
|
+
configurable: true,
|
|
2341
|
+
};
|
|
2342
|
+
}
|
|
2343
|
+
function createPublicAccessorDescriptor(key, descriptor) {
|
|
2344
|
+
const { get, set, enumerable, configurable } = descriptor;
|
|
2345
|
+
if (!isFunction$1(get)) {
|
|
2346
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2347
|
+
assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
|
|
2348
|
+
}
|
|
2349
|
+
throw new Error();
|
|
2350
|
+
}
|
|
2351
|
+
return {
|
|
2352
|
+
get() {
|
|
2353
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2354
|
+
// Assert that the this value is an actual Component with an associated VM.
|
|
2355
|
+
getAssociatedVM(this);
|
|
2356
|
+
}
|
|
2357
|
+
return get.call(this);
|
|
2358
|
+
},
|
|
2359
|
+
set(newValue) {
|
|
2360
|
+
const vm = getAssociatedVM(this);
|
|
2361
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2362
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2363
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2364
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2365
|
+
}
|
|
2366
|
+
if (set) {
|
|
2367
|
+
set.call(this, newValue);
|
|
2368
|
+
}
|
|
2369
|
+
else if (process.env.NODE_ENV !== 'production') {
|
|
2370
|
+
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.`);
|
|
2371
|
+
}
|
|
2372
|
+
},
|
|
2373
|
+
enumerable,
|
|
2374
|
+
configurable,
|
|
2375
|
+
};
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
/*
|
|
2379
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2380
|
+
* All rights reserved.
|
|
2381
|
+
* SPDX-License-Identifier: MIT
|
|
2382
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2383
|
+
*/
|
|
2384
|
+
function track(target) {
|
|
2385
|
+
if (arguments.length === 1) {
|
|
2386
|
+
return getReactiveProxy(target);
|
|
2387
|
+
}
|
|
2388
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2389
|
+
assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
|
|
2390
|
+
}
|
|
2391
|
+
throw new Error();
|
|
2392
|
+
}
|
|
2393
|
+
function internalTrackDecorator(key) {
|
|
2394
|
+
return {
|
|
2018
2395
|
get() {
|
|
2019
2396
|
const vm = getAssociatedVM(this);
|
|
2020
2397
|
componentValueObserved(vm, key);
|
|
@@ -5792,286 +6169,143 @@ function forceRehydration(vm) {
|
|
|
5792
6169
|
* SPDX-License-Identifier: MIT
|
|
5793
6170
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5794
6171
|
*/
|
|
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
|
-
|
|
6172
|
+
//
|
|
6173
|
+
// The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
|
|
6174
|
+
// These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
|
|
6175
|
+
// When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
|
|
6176
|
+
// See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
|
|
6177
|
+
//
|
|
6178
|
+
// Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
|
|
6179
|
+
const getElementById = globalThis$1[KEY__NATIVE_GET_ELEMENT_BY_ID];
|
|
6180
|
+
const querySelectorAll = globalThis$1[KEY__NATIVE_QUERY_SELECTOR_ALL];
|
|
6181
|
+
function isSyntheticShadowRootInstance(rootNode) {
|
|
6182
|
+
return rootNode !== document && isTrue(rootNode.synthetic);
|
|
6183
|
+
}
|
|
6184
|
+
function reportViolation(source, target, attrName) {
|
|
6185
|
+
// The vm is either for the source, the target, or both. Either one or both must be using synthetic
|
|
6186
|
+
// shadow for a violation to be detected.
|
|
6187
|
+
let vm = getAssociatedVMIfPresent(source.getRootNode().host);
|
|
6188
|
+
if (isUndefined$1(vm)) {
|
|
6189
|
+
vm = getAssociatedVMIfPresent(target.getRootNode().host);
|
|
6190
|
+
}
|
|
6191
|
+
if (isUndefined$1(vm)) {
|
|
6192
|
+
// vm should never be undefined here, but just to be safe, bail out and don't report
|
|
6193
|
+
return;
|
|
6194
|
+
}
|
|
6195
|
+
report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
|
|
6196
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6197
|
+
// Avoid excessively logging to the console in the case of duplicates.
|
|
6198
|
+
logWarnOnce(`Element <${source.tagName.toLowerCase()}> uses attribute "${attrName}" to reference element ` +
|
|
6199
|
+
`<${target.tagName.toLowerCase()}>, which is not in the same shadow root. This will break in native shadow DOM. ` +
|
|
6200
|
+
`For details, see: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates`, vm);
|
|
6201
|
+
}
|
|
5822
6202
|
}
|
|
5823
|
-
function
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
runWithBoundaryProtection(vm, vm.owner, noop, () => {
|
|
5827
|
-
// job
|
|
5828
|
-
method.call(vm.component, value);
|
|
5829
|
-
}, noop);
|
|
5830
|
-
};
|
|
6203
|
+
function parseIdRefAttributeValue(attrValue) {
|
|
6204
|
+
// split on whitespace and skip empty strings after splitting
|
|
6205
|
+
return isString(attrValue) ? ArrayFilter.call(StringSplit.call(attrValue, /\s+/), Boolean) : [];
|
|
5831
6206
|
}
|
|
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
|
-
});
|
|
6207
|
+
function detectSyntheticCrossRootAria(elm, attrName, attrValue) {
|
|
6208
|
+
const root = elm.getRootNode();
|
|
6209
|
+
if (!isSyntheticShadowRootInstance(root)) {
|
|
6210
|
+
return;
|
|
5846
6211
|
}
|
|
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
|
-
|
|
6212
|
+
if (attrName === 'id') {
|
|
6213
|
+
// elm is the target, find the source
|
|
6214
|
+
if (!isString(attrValue) || attrValue.length === 0) {
|
|
6215
|
+
// if our id is null or empty, nobody can reference us
|
|
6216
|
+
return;
|
|
6217
|
+
}
|
|
6218
|
+
for (const idRefAttrName of ID_REFERENCING_ATTRIBUTES_SET) {
|
|
6219
|
+
// Query all global elements with this attribute. The attribute selector syntax `~=` is for values
|
|
6220
|
+
// that reference multiple IDs, separated by whitespace.
|
|
6221
|
+
const query = `[${idRefAttrName}~="${CSS.escape(attrValue)}"]`;
|
|
6222
|
+
const sourceElements = querySelectorAll.call(document, query);
|
|
6223
|
+
for (let i = 0; i < sourceElements.length; i++) {
|
|
6224
|
+
const sourceElement = sourceElements[i];
|
|
6225
|
+
const sourceRoot = sourceElement.getRootNode();
|
|
6226
|
+
if (sourceRoot !== root) {
|
|
6227
|
+
reportViolation(sourceElement, elm, idRefAttrName);
|
|
6228
|
+
break;
|
|
6229
|
+
}
|
|
6230
|
+
}
|
|
6231
|
+
}
|
|
6232
|
+
}
|
|
6233
|
+
else {
|
|
6234
|
+
// elm is the source, find the target
|
|
6235
|
+
const ids = parseIdRefAttributeValue(attrValue);
|
|
6236
|
+
for (const id of ids) {
|
|
6237
|
+
const target = getElementById.call(document, id);
|
|
6238
|
+
if (!isNull(target)) {
|
|
6239
|
+
const targetRoot = target.getRootNode();
|
|
6240
|
+
if (targetRoot !== root) {
|
|
6241
|
+
// target element's shadow root is not the same as ours
|
|
6242
|
+
reportViolation(elm, target, attrName);
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
}
|
|
5878
6246
|
}
|
|
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
6247
|
}
|
|
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;
|
|
6248
|
+
let enabled = false;
|
|
6249
|
+
// We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
|
|
6250
|
+
// reporting is not enabled. It should also only run once
|
|
6251
|
+
function enableDetection() {
|
|
6252
|
+
if (enabled) {
|
|
6253
|
+
return; // don't double-apply the patches
|
|
5924
6254
|
}
|
|
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
|
-
}
|
|
6255
|
+
enabled = true;
|
|
6256
|
+
const { setAttribute } = Element.prototype;
|
|
6257
|
+
// Detect calling `setAttribute` to set an idref or an id
|
|
6258
|
+
assign(Element.prototype, {
|
|
6259
|
+
setAttribute(attrName, attrValue) {
|
|
6260
|
+
setAttribute.call(this, attrName, attrValue);
|
|
6261
|
+
if (attrName === 'id' || ID_REFERENCING_ATTRIBUTES_SET.has(attrName)) {
|
|
6262
|
+
detectSyntheticCrossRootAria(this, attrName, attrValue);
|
|
6263
|
+
}
|
|
6264
|
+
},
|
|
5973
6265
|
});
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
6266
|
+
// Detect `elm.id = 'foo'`
|
|
6267
|
+
const idDescriptor = getOwnPropertyDescriptor$1(Element.prototype, 'id');
|
|
6268
|
+
if (!isUndefined$1(idDescriptor)) {
|
|
6269
|
+
const { get, set } = idDescriptor;
|
|
6270
|
+
// These should always be a getter and a setter, but if someone is monkeying with the global descriptor, ignore it
|
|
6271
|
+
if (isFunction$1(get) && isFunction$1(set)) {
|
|
6272
|
+
defineProperty(Element.prototype, 'id', {
|
|
6273
|
+
get() {
|
|
6274
|
+
return get.call(this);
|
|
6275
|
+
},
|
|
6276
|
+
set(value) {
|
|
6277
|
+
set.call(this, value);
|
|
6278
|
+
detectSyntheticCrossRootAria(this, 'id', value);
|
|
6279
|
+
},
|
|
6280
|
+
// On the default descriptor for 'id', enumerable and configurable are true
|
|
6281
|
+
enumerable: true,
|
|
6282
|
+
configurable: true,
|
|
6283
|
+
});
|
|
6284
|
+
}
|
|
6285
|
+
}
|
|
5988
6286
|
}
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
}
|
|
5994
|
-
const method = descriptor.value;
|
|
5995
|
-
const def = {
|
|
5996
|
-
adapter,
|
|
5997
|
-
method,
|
|
5998
|
-
configCallback,
|
|
5999
|
-
dynamic
|
|
6000
|
-
};
|
|
6001
|
-
WireMetaMap.set(descriptor, def);
|
|
6287
|
+
// Our detection logic relies on some modern browser features. We can just skip reporting the data
|
|
6288
|
+
// for unsupported browsers
|
|
6289
|
+
function supportsCssEscape() {
|
|
6290
|
+
return typeof CSS !== 'undefined' && isFunction$1(CSS.escape);
|
|
6002
6291
|
}
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
adapter,
|
|
6010
|
-
configCallback,
|
|
6011
|
-
dynamic
|
|
6012
|
-
};
|
|
6013
|
-
WireMetaMap.set(descriptor, def);
|
|
6292
|
+
// If this page is not using synthetic shadow, then we don't need to install detection. Note
|
|
6293
|
+
// that we are assuming synthetic shadow is loaded before LWC.
|
|
6294
|
+
function isSyntheticShadowLoaded() {
|
|
6295
|
+
// We should probably be calling `renderer.isSyntheticShadowDefined`, but 1) we don't have access to the renderer,
|
|
6296
|
+
// and 2) this code needs to run in @lwc/engine-core, so it can access `logWarn()` and `report()`.
|
|
6297
|
+
return hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
|
|
6014
6298
|
}
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
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);
|
|
6299
|
+
// Detecting cross-root ARIA in synthetic shadow only makes sense for the browser
|
|
6300
|
+
if (process.env.IS_BROWSER && supportsCssEscape() && isSyntheticShadowLoaded()) {
|
|
6301
|
+
// Always run detection in dev mode, so we can at least print to the console
|
|
6030
6302
|
if (process.env.NODE_ENV !== 'production') {
|
|
6031
|
-
|
|
6032
|
-
}
|
|
6033
|
-
if (!isUndefined$1(wireDef)) {
|
|
6034
|
-
const {
|
|
6035
|
-
connector,
|
|
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
|
-
});
|
|
6303
|
+
enableDetection();
|
|
6054
6304
|
}
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
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]();
|
|
6305
|
+
else {
|
|
6306
|
+
// In prod mode, only enable detection if reporting is enabled
|
|
6307
|
+
onReportingEnabled(enableDetection);
|
|
6073
6308
|
}
|
|
6074
|
-
}, noop);
|
|
6075
6309
|
}
|
|
6076
6310
|
|
|
6077
6311
|
/*
|
|
@@ -6744,5 +6978,5 @@ function getComponentConstructor(elm) {
|
|
|
6744
6978
|
return ctor;
|
|
6745
6979
|
}
|
|
6746
6980
|
|
|
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.
|
|
6981
|
+
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 };
|
|
6982
|
+
/* version: 2.35.0 */
|