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