lwc 2.33.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-dom/esm/es2017/engine-dom.js +1022 -649
- package/dist/engine-dom/iife/es2017/engine-dom.js +1022 -648
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +824 -557
- package/dist/engine-dom/iife/es5/engine-dom.js +1179 -802
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +1002 -720
- package/dist/engine-dom/umd/es2017/engine-dom.js +1022 -648
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +824 -557
- package/dist/engine-dom/umd/es5/engine-dom.js +1179 -802
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +1002 -720
- package/dist/engine-server/commonjs/es2017/engine-server.js +789 -638
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +789 -638
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +15 -4
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +15 -4
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +15 -4
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +18 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +18 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +15 -4
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +15 -4
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +18 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +18 -3
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +7 -7
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
const { isArray: isArray$1 } = Array;
|
|
52
52
|
const { concat: ArrayConcat$1, copyWithin: ArrayCopyWithin, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
|
|
53
53
|
const { fromCharCode: StringFromCharCode } = String;
|
|
54
|
-
const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
|
|
54
|
+
const { charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
|
|
55
55
|
function isUndefined$1(obj) {
|
|
56
56
|
return obj === undefined;
|
|
57
57
|
}
|
|
@@ -185,6 +185,19 @@
|
|
|
185
185
|
});
|
|
186
186
|
return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap };
|
|
187
187
|
})();
|
|
188
|
+
// These attributes take either an ID or a list of IDs as values.
|
|
189
|
+
// This includes aria-* attributes as well as the special non-ARIA "for" attribute
|
|
190
|
+
const ID_REFERENCING_ATTRIBUTES_SET = new Set([
|
|
191
|
+
'aria-activedescendant',
|
|
192
|
+
'aria-controls',
|
|
193
|
+
'aria-describedby',
|
|
194
|
+
'aria-details',
|
|
195
|
+
'aria-errormessage',
|
|
196
|
+
'aria-flowto',
|
|
197
|
+
'aria-labelledby',
|
|
198
|
+
'aria-owns',
|
|
199
|
+
'for',
|
|
200
|
+
]);
|
|
188
201
|
|
|
189
202
|
/*
|
|
190
203
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -240,6 +253,8 @@
|
|
|
240
253
|
const KEY__SHADOW_TOKEN = '$shadowToken$';
|
|
241
254
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
|
242
255
|
const KEY__SCOPED_CSS = '$scoped$';
|
|
256
|
+
const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
|
|
257
|
+
const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
|
243
258
|
const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
244
259
|
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
245
260
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
@@ -339,7 +354,7 @@
|
|
|
339
354
|
CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
|
|
340
355
|
return propertyName;
|
|
341
356
|
}
|
|
342
|
-
/** version: 2.
|
|
357
|
+
/** version: 2.35.0 */
|
|
343
358
|
|
|
344
359
|
/**
|
|
345
360
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -362,6 +377,7 @@
|
|
|
362
377
|
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
363
378
|
ENABLE_FROZEN_TEMPLATE: null,
|
|
364
379
|
DISABLE_ARIA_REFLECTION_POLYFILL: null,
|
|
380
|
+
ENABLE_PROGRAMMATIC_STYLESHEETS: null,
|
|
365
381
|
};
|
|
366
382
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
367
383
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -405,7 +421,7 @@
|
|
|
405
421
|
*/
|
|
406
422
|
function setFeatureFlagForTest(name, value) {
|
|
407
423
|
}
|
|
408
|
-
/** version: 2.
|
|
424
|
+
/** version: 2.35.0 */
|
|
409
425
|
|
|
410
426
|
/**
|
|
411
427
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -469,7 +485,7 @@
|
|
|
469
485
|
}
|
|
470
486
|
}
|
|
471
487
|
}
|
|
472
|
-
/** version: 2.
|
|
488
|
+
/** version: 2.35.0 */
|
|
473
489
|
|
|
474
490
|
/*
|
|
475
491
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -489,69 +505,148 @@
|
|
|
489
505
|
* SPDX-License-Identifier: MIT
|
|
490
506
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
491
507
|
*/
|
|
492
|
-
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
508
|
+
/** Callbacks to invoke when reporting is enabled **/
|
|
509
|
+
const onReportingEnabledCallbacks = [];
|
|
510
|
+
/** The currently assigned reporting dispatcher. */
|
|
511
|
+
let currentDispatcher$1 = noop;
|
|
512
|
+
/**
|
|
513
|
+
* Whether reporting is enabled.
|
|
514
|
+
*
|
|
515
|
+
* Note that this may seem redundant, given you can just check if the currentDispatcher is undefined,
|
|
516
|
+
* but it turns out that Terser only strips out unused code if we use this explicit boolean.
|
|
517
|
+
*/
|
|
518
|
+
let enabled$1 = false;
|
|
519
|
+
const reportingControl = {
|
|
520
|
+
/**
|
|
521
|
+
* Attach a new reporting control (aka dispatcher).
|
|
522
|
+
*
|
|
523
|
+
* @param dispatcher - reporting control
|
|
524
|
+
*/
|
|
525
|
+
attachDispatcher(dispatcher) {
|
|
526
|
+
enabled$1 = true;
|
|
527
|
+
currentDispatcher$1 = dispatcher;
|
|
528
|
+
for (const callback of onReportingEnabledCallbacks) {
|
|
529
|
+
try {
|
|
530
|
+
callback();
|
|
531
|
+
}
|
|
532
|
+
catch (err) {
|
|
533
|
+
// This should never happen. But if it does, we don't want one callback to cause another to fail
|
|
534
|
+
// eslint-disable-next-line no-console
|
|
535
|
+
console.error('Could not invoke callback', err);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
onReportingEnabledCallbacks.length = 0; // clear the array
|
|
539
|
+
},
|
|
540
|
+
/**
|
|
541
|
+
* Detach the current reporting control (aka dispatcher).
|
|
542
|
+
*/
|
|
543
|
+
detachDispatcher() {
|
|
544
|
+
enabled$1 = false;
|
|
545
|
+
currentDispatcher$1 = noop;
|
|
546
|
+
},
|
|
547
|
+
};
|
|
548
|
+
/**
|
|
549
|
+
* Call a callback when reporting is enabled, or immediately if reporting is already enabled.
|
|
550
|
+
* Will only ever be called once.
|
|
551
|
+
* @param callback
|
|
552
|
+
*/
|
|
553
|
+
function onReportingEnabled(callback) {
|
|
554
|
+
if (enabled$1) {
|
|
555
|
+
// call immediately
|
|
556
|
+
callback();
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
// call later
|
|
560
|
+
onReportingEnabledCallbacks.push(callback);
|
|
501
561
|
}
|
|
502
562
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
563
|
+
/**
|
|
564
|
+
* Report to the current dispatcher, if there is one.
|
|
565
|
+
* @param reportingEventId
|
|
566
|
+
* @param vm
|
|
567
|
+
*/
|
|
568
|
+
function report(reportingEventId, vm) {
|
|
569
|
+
if (enabled$1) {
|
|
570
|
+
currentDispatcher$1(reportingEventId, vm.tagName, vm.idx);
|
|
506
571
|
}
|
|
507
|
-
ArrayPush$1.call(nextTickCallbackQueue, callback);
|
|
508
572
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
573
|
+
|
|
574
|
+
/*
|
|
575
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
576
|
+
* All rights reserved.
|
|
577
|
+
* SPDX-License-Identifier: MIT
|
|
578
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
579
|
+
*/
|
|
580
|
+
function getComponentTag(vm) {
|
|
581
|
+
return `<${StringToLowerCase.call(vm.tagName)}>`;
|
|
582
|
+
}
|
|
583
|
+
// TODO [#1695]: Unify getComponentStack and getErrorComponentStack
|
|
584
|
+
function getComponentStack(vm) {
|
|
585
|
+
const stack = [];
|
|
586
|
+
let prefix = '';
|
|
587
|
+
while (!isNull(vm.owner)) {
|
|
588
|
+
ArrayPush$1.call(stack, prefix + getComponentTag(vm));
|
|
589
|
+
vm = vm.owner;
|
|
590
|
+
prefix += '\t';
|
|
514
591
|
}
|
|
515
|
-
return
|
|
592
|
+
return ArrayJoin.call(stack, '\n');
|
|
516
593
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
const declarations = cssText.split(DECLARATION_DELIMITER);
|
|
524
|
-
for (const declaration of declarations) {
|
|
525
|
-
if (declaration) {
|
|
526
|
-
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
|
527
|
-
if (prop !== undefined && value !== undefined) {
|
|
528
|
-
styleMap[prop.trim()] = value.trim();
|
|
529
|
-
}
|
|
530
|
-
}
|
|
594
|
+
function getErrorComponentStack(vm) {
|
|
595
|
+
const wcStack = [];
|
|
596
|
+
let currentVm = vm;
|
|
597
|
+
while (!isNull(currentVm)) {
|
|
598
|
+
ArrayPush$1.call(wcStack, getComponentTag(currentVm));
|
|
599
|
+
currentVm = currentVm.owner;
|
|
531
600
|
}
|
|
532
|
-
return
|
|
601
|
+
return wcStack.reverse().join('\n\t');
|
|
533
602
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
603
|
+
|
|
604
|
+
/*
|
|
605
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
606
|
+
* All rights reserved.
|
|
607
|
+
* SPDX-License-Identifier: MIT
|
|
608
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
609
|
+
*/
|
|
610
|
+
function addErrorComponentStack(vm, error) {
|
|
611
|
+
if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
|
|
612
|
+
const wcStack = getErrorComponentStack(vm);
|
|
613
|
+
defineProperty(error, 'wcStack', {
|
|
614
|
+
get() {
|
|
615
|
+
return wcStack;
|
|
616
|
+
},
|
|
617
|
+
});
|
|
541
618
|
}
|
|
542
|
-
return result;
|
|
543
619
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
620
|
+
|
|
621
|
+
/*
|
|
622
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
623
|
+
* All rights reserved.
|
|
624
|
+
* SPDX-License-Identifier: MIT
|
|
625
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
626
|
+
*/
|
|
627
|
+
const alreadyLoggedMessages = new Set();
|
|
628
|
+
function log(method, message, vm, once) {
|
|
629
|
+
let msg = `[LWC ${method}]: ${message}`;
|
|
630
|
+
if (!isUndefined$1(vm)) {
|
|
631
|
+
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
632
|
+
}
|
|
633
|
+
if (once) {
|
|
634
|
+
if (alreadyLoggedMessages.has(msg)) {
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
alreadyLoggedMessages.add(msg);
|
|
638
|
+
}
|
|
639
|
+
try {
|
|
640
|
+
throw new Error(msg);
|
|
641
|
+
}
|
|
642
|
+
catch (e) {
|
|
643
|
+
/* eslint-disable-next-line no-console */
|
|
644
|
+
console[method](e);
|
|
553
645
|
}
|
|
554
646
|
}
|
|
647
|
+
function logError(message, vm) {
|
|
648
|
+
log('error', message, vm, false);
|
|
649
|
+
}
|
|
555
650
|
|
|
556
651
|
/*
|
|
557
652
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
@@ -673,68 +768,80 @@
|
|
|
673
768
|
* SPDX-License-Identifier: MIT
|
|
674
769
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
675
770
|
*/
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
function
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
vm = vm.owner;
|
|
686
|
-
prefix += '\t';
|
|
771
|
+
let nextTickCallbackQueue = [];
|
|
772
|
+
const SPACE_CHAR = 32;
|
|
773
|
+
const EmptyObject = seal(create(null));
|
|
774
|
+
const EmptyArray = seal([]);
|
|
775
|
+
function flushCallbackQueue() {
|
|
776
|
+
const callbacks = nextTickCallbackQueue;
|
|
777
|
+
nextTickCallbackQueue = []; // reset to a new queue
|
|
778
|
+
for (let i = 0, len = callbacks.length; i < len; i += 1) {
|
|
779
|
+
callbacks[i]();
|
|
687
780
|
}
|
|
688
|
-
return ArrayJoin.call(stack, '\n');
|
|
689
781
|
}
|
|
690
|
-
function
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
while (!isNull(currentVm)) {
|
|
694
|
-
ArrayPush$1.call(wcStack, getComponentTag(currentVm));
|
|
695
|
-
currentVm = currentVm.owner;
|
|
782
|
+
function addCallbackToNextTick(callback) {
|
|
783
|
+
if (nextTickCallbackQueue.length === 0) {
|
|
784
|
+
Promise.resolve().then(flushCallbackQueue);
|
|
696
785
|
}
|
|
697
|
-
|
|
786
|
+
ArrayPush$1.call(nextTickCallbackQueue, callback);
|
|
698
787
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
705
|
-
*/
|
|
706
|
-
function addErrorComponentStack(vm, error) {
|
|
707
|
-
if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
|
|
708
|
-
const wcStack = getErrorComponentStack(vm);
|
|
709
|
-
defineProperty(error, 'wcStack', {
|
|
710
|
-
get() {
|
|
711
|
-
return wcStack;
|
|
712
|
-
},
|
|
713
|
-
});
|
|
788
|
+
function guid() {
|
|
789
|
+
function s4() {
|
|
790
|
+
return Math.floor((1 + Math.random()) * 0x10000)
|
|
791
|
+
.toString(16)
|
|
792
|
+
.substring(1);
|
|
714
793
|
}
|
|
794
|
+
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
715
795
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
796
|
+
// Borrowed from Vue template compiler.
|
|
797
|
+
// https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
|
|
798
|
+
const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
|
|
799
|
+
const PROPERTY_DELIMITER = /:(.+)/;
|
|
800
|
+
function parseStyleText(cssText) {
|
|
801
|
+
const styleMap = {};
|
|
802
|
+
const declarations = cssText.split(DECLARATION_DELIMITER);
|
|
803
|
+
for (const declaration of declarations) {
|
|
804
|
+
if (declaration) {
|
|
805
|
+
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
|
806
|
+
if (prop !== undefined && value !== undefined) {
|
|
807
|
+
styleMap[prop.trim()] = value.trim();
|
|
808
|
+
}
|
|
809
|
+
}
|
|
727
810
|
}
|
|
728
|
-
|
|
729
|
-
|
|
811
|
+
return styleMap;
|
|
812
|
+
}
|
|
813
|
+
// Make a shallow copy of an object but omit the given key
|
|
814
|
+
function cloneAndOmitKey(object, keyToOmit) {
|
|
815
|
+
const result = {};
|
|
816
|
+
for (const key of Object.keys(object)) {
|
|
817
|
+
if (key !== keyToOmit) {
|
|
818
|
+
result[key] = object[key];
|
|
819
|
+
}
|
|
730
820
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
821
|
+
return result;
|
|
822
|
+
}
|
|
823
|
+
function flattenStylesheets(stylesheets) {
|
|
824
|
+
const list = [];
|
|
825
|
+
for (const stylesheet of stylesheets) {
|
|
826
|
+
if (!Array.isArray(stylesheet)) {
|
|
827
|
+
list.push(stylesheet);
|
|
828
|
+
}
|
|
829
|
+
else {
|
|
830
|
+
list.push(...flattenStylesheets(stylesheet));
|
|
831
|
+
}
|
|
734
832
|
}
|
|
833
|
+
return list;
|
|
735
834
|
}
|
|
736
|
-
|
|
737
|
-
|
|
835
|
+
// Set a ref (lwc:ref) on a VM, from a template API
|
|
836
|
+
function setRefVNode(vm, ref, vnode) {
|
|
837
|
+
// If this method is called, then vm.refVNodes is set as the template has refs.
|
|
838
|
+
// If not, then something went wrong and we threw an error above.
|
|
839
|
+
const refVNodes = vm.refVNodes;
|
|
840
|
+
// In cases of conflict (two elements with the same ref), prefer, the last one,
|
|
841
|
+
// in depth-first traversal order.
|
|
842
|
+
if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
|
|
843
|
+
refVNodes[ref] = vnode;
|
|
844
|
+
}
|
|
738
845
|
}
|
|
739
846
|
|
|
740
847
|
/*
|
|
@@ -780,98 +887,6 @@
|
|
|
780
887
|
'tabIndex',
|
|
781
888
|
'title',
|
|
782
889
|
];
|
|
783
|
-
function offsetPropertyErrorMessage(name) {
|
|
784
|
-
return `Using the \`${name}\` property is an anti-pattern because it rounds the value to an integer. Instead, use the \`getBoundingClientRect\` method to obtain fractional values for the size of an element and its position relative to the viewport.`;
|
|
785
|
-
}
|
|
786
|
-
// Global HTML Attributes & Properties
|
|
787
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
|
|
788
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
|
|
789
|
-
assign(create(null), {
|
|
790
|
-
accessKey: {
|
|
791
|
-
attribute: 'accesskey',
|
|
792
|
-
},
|
|
793
|
-
accessKeyLabel: {
|
|
794
|
-
readOnly: true,
|
|
795
|
-
},
|
|
796
|
-
className: {
|
|
797
|
-
attribute: 'class',
|
|
798
|
-
error: 'Using the `className` property is an anti-pattern because of slow runtime behavior and potential conflicts with classes provided by the owner element. Use the `classList` API instead.',
|
|
799
|
-
},
|
|
800
|
-
contentEditable: {
|
|
801
|
-
attribute: 'contenteditable',
|
|
802
|
-
},
|
|
803
|
-
dataset: {
|
|
804
|
-
readOnly: true,
|
|
805
|
-
error: "Using the `dataset` property is an anti-pattern because it can't be statically analyzed. Expose each property individually using the `@api` decorator instead.",
|
|
806
|
-
},
|
|
807
|
-
dir: {
|
|
808
|
-
attribute: 'dir',
|
|
809
|
-
},
|
|
810
|
-
draggable: {
|
|
811
|
-
attribute: 'draggable',
|
|
812
|
-
},
|
|
813
|
-
dropzone: {
|
|
814
|
-
attribute: 'dropzone',
|
|
815
|
-
readOnly: true,
|
|
816
|
-
},
|
|
817
|
-
hidden: {
|
|
818
|
-
attribute: 'hidden',
|
|
819
|
-
},
|
|
820
|
-
id: {
|
|
821
|
-
attribute: 'id',
|
|
822
|
-
},
|
|
823
|
-
inputMode: {
|
|
824
|
-
attribute: 'inputmode',
|
|
825
|
-
},
|
|
826
|
-
lang: {
|
|
827
|
-
attribute: 'lang',
|
|
828
|
-
},
|
|
829
|
-
slot: {
|
|
830
|
-
attribute: 'slot',
|
|
831
|
-
error: 'Using the `slot` property is an anti-pattern.',
|
|
832
|
-
},
|
|
833
|
-
spellcheck: {
|
|
834
|
-
attribute: 'spellcheck',
|
|
835
|
-
},
|
|
836
|
-
style: {
|
|
837
|
-
attribute: 'style',
|
|
838
|
-
},
|
|
839
|
-
tabIndex: {
|
|
840
|
-
attribute: 'tabindex',
|
|
841
|
-
},
|
|
842
|
-
title: {
|
|
843
|
-
attribute: 'title',
|
|
844
|
-
},
|
|
845
|
-
translate: {
|
|
846
|
-
attribute: 'translate',
|
|
847
|
-
},
|
|
848
|
-
// additional "global attributes" that are not present in the link above.
|
|
849
|
-
isContentEditable: {
|
|
850
|
-
readOnly: true,
|
|
851
|
-
},
|
|
852
|
-
offsetHeight: {
|
|
853
|
-
readOnly: true,
|
|
854
|
-
error: offsetPropertyErrorMessage('offsetHeight'),
|
|
855
|
-
},
|
|
856
|
-
offsetLeft: {
|
|
857
|
-
readOnly: true,
|
|
858
|
-
error: offsetPropertyErrorMessage('offsetLeft'),
|
|
859
|
-
},
|
|
860
|
-
offsetParent: {
|
|
861
|
-
readOnly: true,
|
|
862
|
-
},
|
|
863
|
-
offsetTop: {
|
|
864
|
-
readOnly: true,
|
|
865
|
-
error: offsetPropertyErrorMessage('offsetTop'),
|
|
866
|
-
},
|
|
867
|
-
offsetWidth: {
|
|
868
|
-
readOnly: true,
|
|
869
|
-
error: offsetPropertyErrorMessage('offsetWidth'),
|
|
870
|
-
},
|
|
871
|
-
role: {
|
|
872
|
-
attribute: 'role',
|
|
873
|
-
},
|
|
874
|
-
});
|
|
875
890
|
let controlledElement = null;
|
|
876
891
|
let controlledAttributeName;
|
|
877
892
|
function isAttributeLocked(elm, attrName) {
|
|
@@ -1805,92 +1820,356 @@
|
|
|
1805
1820
|
* SPDX-License-Identifier: MIT
|
|
1806
1821
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1807
1822
|
*/
|
|
1808
|
-
|
|
1809
|
-
|
|
1823
|
+
const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
|
|
1824
|
+
const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
|
1825
|
+
const WireMetaMap = new Map();
|
|
1826
|
+
class WireContextRegistrationEvent extends CustomEvent {
|
|
1827
|
+
constructor(adapterToken, {
|
|
1828
|
+
setNewContext,
|
|
1829
|
+
setDisconnectedCallback
|
|
1830
|
+
}) {
|
|
1831
|
+
super(adapterToken, {
|
|
1832
|
+
bubbles: true,
|
|
1833
|
+
composed: true
|
|
1834
|
+
});
|
|
1835
|
+
defineProperties(this, {
|
|
1836
|
+
setNewContext: {
|
|
1837
|
+
value: setNewContext
|
|
1838
|
+
},
|
|
1839
|
+
setDisconnectedCallback: {
|
|
1840
|
+
value: setDisconnectedCallback
|
|
1841
|
+
}
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1810
1844
|
}
|
|
1811
|
-
function
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
if (isBeingConstructed(vm)) {
|
|
1816
|
-
return;
|
|
1817
|
-
}
|
|
1818
|
-
componentValueObserved(vm, key);
|
|
1819
|
-
return vm.cmpProps[key];
|
|
1820
|
-
},
|
|
1821
|
-
set(newValue) {
|
|
1822
|
-
const vm = getAssociatedVM(this);
|
|
1823
|
-
vm.cmpProps[key] = newValue;
|
|
1824
|
-
componentValueMutated(vm, key);
|
|
1825
|
-
},
|
|
1826
|
-
enumerable: true,
|
|
1827
|
-
configurable: true,
|
|
1828
|
-
};
|
|
1845
|
+
function createFieldDataCallback(vm, name) {
|
|
1846
|
+
return value => {
|
|
1847
|
+
updateComponentValue(vm, name, value);
|
|
1848
|
+
};
|
|
1829
1849
|
}
|
|
1830
|
-
function
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1850
|
+
function createMethodDataCallback(vm, method) {
|
|
1851
|
+
return value => {
|
|
1852
|
+
// dispatching new value into the wired method
|
|
1853
|
+
runWithBoundaryProtection(vm, vm.owner, noop, () => {
|
|
1854
|
+
// job
|
|
1855
|
+
method.call(vm.component, value);
|
|
1856
|
+
}, noop);
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1859
|
+
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
1860
|
+
let hasPendingConfig = false;
|
|
1861
|
+
// creating the reactive observer for reactive params when needed
|
|
1862
|
+
const ro = createReactiveObserver(() => {
|
|
1863
|
+
if (hasPendingConfig === false) {
|
|
1864
|
+
hasPendingConfig = true;
|
|
1865
|
+
// collect new config in the micro-task
|
|
1866
|
+
Promise.resolve().then(() => {
|
|
1867
|
+
hasPendingConfig = false;
|
|
1868
|
+
// resetting current reactive params
|
|
1869
|
+
ro.reset();
|
|
1870
|
+
// dispatching a new config due to a change in the configuration
|
|
1871
|
+
computeConfigAndUpdate();
|
|
1872
|
+
});
|
|
1834
1873
|
}
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1874
|
+
});
|
|
1875
|
+
const computeConfigAndUpdate = () => {
|
|
1876
|
+
let config;
|
|
1877
|
+
ro.observe(() => config = configCallback(component));
|
|
1878
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
1879
|
+
// TODO: dev-mode validation of config based on the adapter.configSchema
|
|
1880
|
+
// @ts-ignore it is assigned in the observe() callback
|
|
1881
|
+
callbackWhenConfigIsReady(config);
|
|
1882
|
+
};
|
|
1883
|
+
return {
|
|
1884
|
+
computeConfigAndUpdate,
|
|
1885
|
+
ro
|
|
1886
|
+
};
|
|
1848
1887
|
}
|
|
1888
|
+
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
1889
|
+
const {
|
|
1890
|
+
adapter
|
|
1891
|
+
} = wireDef;
|
|
1892
|
+
const adapterContextToken = getAdapterToken(adapter);
|
|
1893
|
+
if (isUndefined$1(adapterContextToken)) {
|
|
1894
|
+
return; // no provider found, nothing to be done
|
|
1895
|
+
}
|
|
1849
1896
|
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
return getReactiveProxy(target);
|
|
1897
|
+
const {
|
|
1898
|
+
elm,
|
|
1899
|
+
context: {
|
|
1900
|
+
wiredConnecting,
|
|
1901
|
+
wiredDisconnecting
|
|
1902
|
+
},
|
|
1903
|
+
renderer: {
|
|
1904
|
+
dispatchEvent
|
|
1859
1905
|
}
|
|
1860
|
-
|
|
1906
|
+
} = vm;
|
|
1907
|
+
// waiting for the component to be connected to formally request the context via the token
|
|
1908
|
+
ArrayPush$1.call(wiredConnecting, () => {
|
|
1909
|
+
// This event is responsible for connecting the host element with another
|
|
1910
|
+
// element in the composed path that is providing contextual data. The provider
|
|
1911
|
+
// must be listening for a special dom event with the name corresponding to the value of
|
|
1912
|
+
// `adapterContextToken`, which will remain secret and internal to this file only to
|
|
1913
|
+
// guarantee that the linkage can be forged.
|
|
1914
|
+
const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
|
|
1915
|
+
setNewContext(newContext) {
|
|
1916
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
1917
|
+
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
1918
|
+
callbackWhenContextIsReady(newContext);
|
|
1919
|
+
},
|
|
1920
|
+
setDisconnectedCallback(disconnectCallback) {
|
|
1921
|
+
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
1922
|
+
// the the element hosting the wire is disconnected
|
|
1923
|
+
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
1924
|
+
}
|
|
1925
|
+
});
|
|
1926
|
+
dispatchEvent(elm, contextRegistrationEvent);
|
|
1927
|
+
});
|
|
1861
1928
|
}
|
|
1862
|
-
function
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1929
|
+
function createConnector(vm, name, wireDef) {
|
|
1930
|
+
const {
|
|
1931
|
+
method,
|
|
1932
|
+
adapter,
|
|
1933
|
+
configCallback,
|
|
1934
|
+
dynamic
|
|
1935
|
+
} = wireDef;
|
|
1936
|
+
let debugInfo;
|
|
1937
|
+
const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
1938
|
+
const dataCallback = value => {
|
|
1939
|
+
fieldOrMethodCallback(value);
|
|
1940
|
+
};
|
|
1941
|
+
let context;
|
|
1942
|
+
let connector;
|
|
1943
|
+
// Workaround to pass the component element associated to this wire adapter instance.
|
|
1944
|
+
defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
1945
|
+
value: vm.elm
|
|
1946
|
+
});
|
|
1947
|
+
defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
|
|
1948
|
+
value: dynamic
|
|
1949
|
+
});
|
|
1950
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
1951
|
+
// job
|
|
1952
|
+
connector = new adapter(dataCallback);
|
|
1953
|
+
}, noop);
|
|
1954
|
+
const updateConnectorConfig = config => {
|
|
1955
|
+
// every time the config is recomputed due to tracking,
|
|
1956
|
+
// this callback will be invoked with the new computed config
|
|
1957
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
1958
|
+
// job
|
|
1959
|
+
if ("production" !== 'production') ;
|
|
1960
|
+
connector.update(config, context);
|
|
1961
|
+
}, noop);
|
|
1962
|
+
};
|
|
1963
|
+
// Computes the current wire config and calls the update method on the wire adapter.
|
|
1964
|
+
// If it has params, we will need to observe changes in the next tick.
|
|
1965
|
+
const {
|
|
1966
|
+
computeConfigAndUpdate,
|
|
1967
|
+
ro
|
|
1968
|
+
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
1969
|
+
// if the adapter needs contextualization, we need to watch for new context and push it alongside the config
|
|
1970
|
+
if (!isUndefined$1(adapter.contextSchema)) {
|
|
1971
|
+
createContextWatcher(vm, wireDef, newContext => {
|
|
1972
|
+
// every time the context is pushed into this component,
|
|
1973
|
+
// this callback will be invoked with the new computed context
|
|
1974
|
+
if (context !== newContext) {
|
|
1975
|
+
context = newContext;
|
|
1976
|
+
// Note: when new context arrives, the config will be recomputed and pushed along side the new
|
|
1977
|
+
// context, this is to preserve the identity characteristics, config should not have identity
|
|
1978
|
+
// (ever), while context can have identity
|
|
1979
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
1980
|
+
computeConfigAndUpdate();
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
return {
|
|
1986
|
+
// @ts-ignore the boundary protection executes sync, connector is always defined
|
|
1987
|
+
connector,
|
|
1988
|
+
computeConfigAndUpdate,
|
|
1989
|
+
resetConfigWatcher: () => ro.reset()
|
|
1990
|
+
};
|
|
1877
1991
|
}
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
* All rights reserved.
|
|
1882
|
-
* SPDX-License-Identifier: MIT
|
|
1883
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1884
|
-
*/
|
|
1885
|
-
/**
|
|
1886
|
-
* @wire decorator to wire fields and methods to a wire adapter in
|
|
1887
|
-
* LWC Components. This function implements the internals of this
|
|
1888
|
-
* decorator.
|
|
1889
|
-
*/
|
|
1890
|
-
function wire(_adapter, _config) {
|
|
1891
|
-
throw new Error();
|
|
1992
|
+
const AdapterToTokenMap = new Map();
|
|
1993
|
+
function getAdapterToken(adapter) {
|
|
1994
|
+
return AdapterToTokenMap.get(adapter);
|
|
1892
1995
|
}
|
|
1893
|
-
function
|
|
1996
|
+
function setAdapterToken(adapter, token) {
|
|
1997
|
+
AdapterToTokenMap.set(adapter, token);
|
|
1998
|
+
}
|
|
1999
|
+
function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2000
|
+
// support for callable adapters
|
|
2001
|
+
if (adapter.adapter) {
|
|
2002
|
+
adapter = adapter.adapter;
|
|
2003
|
+
}
|
|
2004
|
+
const method = descriptor.value;
|
|
2005
|
+
const def = {
|
|
2006
|
+
adapter,
|
|
2007
|
+
method,
|
|
2008
|
+
configCallback,
|
|
2009
|
+
dynamic
|
|
2010
|
+
};
|
|
2011
|
+
WireMetaMap.set(descriptor, def);
|
|
2012
|
+
}
|
|
2013
|
+
function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2014
|
+
// support for callable adapters
|
|
2015
|
+
if (adapter.adapter) {
|
|
2016
|
+
adapter = adapter.adapter;
|
|
2017
|
+
}
|
|
2018
|
+
const def = {
|
|
2019
|
+
adapter,
|
|
2020
|
+
configCallback,
|
|
2021
|
+
dynamic
|
|
2022
|
+
};
|
|
2023
|
+
WireMetaMap.set(descriptor, def);
|
|
2024
|
+
}
|
|
2025
|
+
function installWireAdapters(vm) {
|
|
2026
|
+
const {
|
|
2027
|
+
context,
|
|
2028
|
+
def: {
|
|
2029
|
+
wire
|
|
2030
|
+
}
|
|
2031
|
+
} = vm;
|
|
2032
|
+
const wiredConnecting = context.wiredConnecting = [];
|
|
2033
|
+
const wiredDisconnecting = context.wiredDisconnecting = [];
|
|
2034
|
+
for (const fieldNameOrMethod in wire) {
|
|
2035
|
+
const descriptor = wire[fieldNameOrMethod];
|
|
2036
|
+
const wireDef = WireMetaMap.get(descriptor);
|
|
2037
|
+
if (!isUndefined$1(wireDef)) {
|
|
2038
|
+
const {
|
|
2039
|
+
connector,
|
|
2040
|
+
computeConfigAndUpdate,
|
|
2041
|
+
resetConfigWatcher
|
|
2042
|
+
} = createConnector(vm, fieldNameOrMethod, wireDef);
|
|
2043
|
+
const hasDynamicParams = wireDef.dynamic.length > 0;
|
|
2044
|
+
ArrayPush$1.call(wiredConnecting, () => {
|
|
2045
|
+
connector.connect();
|
|
2046
|
+
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
2047
|
+
if (hasDynamicParams) {
|
|
2048
|
+
Promise.resolve().then(computeConfigAndUpdate);
|
|
2049
|
+
return;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
computeConfigAndUpdate();
|
|
2053
|
+
});
|
|
2054
|
+
ArrayPush$1.call(wiredDisconnecting, () => {
|
|
2055
|
+
connector.disconnect();
|
|
2056
|
+
resetConfigWatcher();
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
function connectWireAdapters(vm) {
|
|
2062
|
+
const {
|
|
2063
|
+
wiredConnecting
|
|
2064
|
+
} = vm.context;
|
|
2065
|
+
for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
|
2066
|
+
wiredConnecting[i]();
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
function disconnectWireAdapters(vm) {
|
|
2070
|
+
const {
|
|
2071
|
+
wiredDisconnecting
|
|
2072
|
+
} = vm.context;
|
|
2073
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2074
|
+
// job
|
|
2075
|
+
for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
|
|
2076
|
+
wiredDisconnecting[i]();
|
|
2077
|
+
}
|
|
2078
|
+
}, noop);
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
/*
|
|
2082
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2083
|
+
* All rights reserved.
|
|
2084
|
+
* SPDX-License-Identifier: MIT
|
|
2085
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2086
|
+
*/
|
|
2087
|
+
function api$1() {
|
|
2088
|
+
throw new Error();
|
|
2089
|
+
}
|
|
2090
|
+
function createPublicPropertyDescriptor(key) {
|
|
2091
|
+
return {
|
|
2092
|
+
get() {
|
|
2093
|
+
const vm = getAssociatedVM(this);
|
|
2094
|
+
if (isBeingConstructed(vm)) {
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
componentValueObserved(vm, key);
|
|
2098
|
+
return vm.cmpProps[key];
|
|
2099
|
+
},
|
|
2100
|
+
set(newValue) {
|
|
2101
|
+
const vm = getAssociatedVM(this);
|
|
2102
|
+
vm.cmpProps[key] = newValue;
|
|
2103
|
+
componentValueMutated(vm, key);
|
|
2104
|
+
},
|
|
2105
|
+
enumerable: true,
|
|
2106
|
+
configurable: true,
|
|
2107
|
+
};
|
|
2108
|
+
}
|
|
2109
|
+
function createPublicAccessorDescriptor(key, descriptor) {
|
|
2110
|
+
const { get, set, enumerable, configurable } = descriptor;
|
|
2111
|
+
if (!isFunction$1(get)) {
|
|
2112
|
+
throw new Error();
|
|
2113
|
+
}
|
|
2114
|
+
return {
|
|
2115
|
+
get() {
|
|
2116
|
+
return get.call(this);
|
|
2117
|
+
},
|
|
2118
|
+
set(newValue) {
|
|
2119
|
+
getAssociatedVM(this);
|
|
2120
|
+
if (set) {
|
|
2121
|
+
set.call(this, newValue);
|
|
2122
|
+
}
|
|
2123
|
+
},
|
|
2124
|
+
enumerable,
|
|
2125
|
+
configurable,
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
/*
|
|
2130
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2131
|
+
* All rights reserved.
|
|
2132
|
+
* SPDX-License-Identifier: MIT
|
|
2133
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2134
|
+
*/
|
|
2135
|
+
function track(target) {
|
|
2136
|
+
if (arguments.length === 1) {
|
|
2137
|
+
return getReactiveProxy(target);
|
|
2138
|
+
}
|
|
2139
|
+
throw new Error();
|
|
2140
|
+
}
|
|
2141
|
+
function internalTrackDecorator(key) {
|
|
2142
|
+
return {
|
|
2143
|
+
get() {
|
|
2144
|
+
const vm = getAssociatedVM(this);
|
|
2145
|
+
componentValueObserved(vm, key);
|
|
2146
|
+
return vm.cmpFields[key];
|
|
2147
|
+
},
|
|
2148
|
+
set(newValue) {
|
|
2149
|
+
const vm = getAssociatedVM(this);
|
|
2150
|
+
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
2151
|
+
updateComponentValue(vm, key, reactiveOrAnyValue);
|
|
2152
|
+
},
|
|
2153
|
+
enumerable: true,
|
|
2154
|
+
configurable: true,
|
|
2155
|
+
};
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
/*
|
|
2159
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2160
|
+
* All rights reserved.
|
|
2161
|
+
* SPDX-License-Identifier: MIT
|
|
2162
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2163
|
+
*/
|
|
2164
|
+
/**
|
|
2165
|
+
* @wire decorator to wire fields and methods to a wire adapter in
|
|
2166
|
+
* LWC Components. This function implements the internals of this
|
|
2167
|
+
* decorator.
|
|
2168
|
+
*/
|
|
2169
|
+
function wire(_adapter, _config) {
|
|
2170
|
+
throw new Error();
|
|
2171
|
+
}
|
|
2172
|
+
function internalWireFieldDecorator(key) {
|
|
1894
2173
|
return {
|
|
1895
2174
|
get() {
|
|
1896
2175
|
const vm = getAssociatedVM(this);
|
|
@@ -2447,6 +2726,9 @@
|
|
|
2447
2726
|
stylesheets: newStylesheets,
|
|
2448
2727
|
stylesheetToken: newStylesheetToken
|
|
2449
2728
|
} = template;
|
|
2729
|
+
const {
|
|
2730
|
+
stylesheets: newVmStylesheets
|
|
2731
|
+
} = vm;
|
|
2450
2732
|
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
2451
2733
|
const {
|
|
2452
2734
|
hasScopedStyles
|
|
@@ -2470,7 +2752,9 @@
|
|
|
2470
2752
|
}
|
|
2471
2753
|
// Apply the new template styling token to the host element, if the new template has any
|
|
2472
2754
|
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
2473
|
-
|
|
2755
|
+
const hasNewStylesheets = hasStyles(newStylesheets);
|
|
2756
|
+
const hasNewVmStylesheets = hasStyles(newVmStylesheets);
|
|
2757
|
+
if (hasNewStylesheets || hasNewVmStylesheets) {
|
|
2474
2758
|
newToken = newStylesheetToken;
|
|
2475
2759
|
}
|
|
2476
2760
|
// Set the new styling token on the host element
|
|
@@ -2534,10 +2818,17 @@
|
|
|
2534
2818
|
stylesheets,
|
|
2535
2819
|
stylesheetToken
|
|
2536
2820
|
} = template;
|
|
2821
|
+
const {
|
|
2822
|
+
stylesheets: vmStylesheets
|
|
2823
|
+
} = vm;
|
|
2537
2824
|
let content = [];
|
|
2538
|
-
if (
|
|
2825
|
+
if (hasStyles(stylesheets)) {
|
|
2539
2826
|
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
2540
2827
|
}
|
|
2828
|
+
// VM (component) stylesheets apply after template stylesheets
|
|
2829
|
+
if (hasStyles(vmStylesheets)) {
|
|
2830
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
|
|
2831
|
+
}
|
|
2541
2832
|
return content;
|
|
2542
2833
|
}
|
|
2543
2834
|
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
@@ -2575,10 +2866,13 @@
|
|
|
2575
2866
|
const {
|
|
2576
2867
|
template
|
|
2577
2868
|
} = getComponentInternalDef(vnode.ctor);
|
|
2869
|
+
const {
|
|
2870
|
+
vm
|
|
2871
|
+
} = vnode;
|
|
2578
2872
|
const {
|
|
2579
2873
|
stylesheetToken
|
|
2580
2874
|
} = template;
|
|
2581
|
-
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
2875
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
|
|
2582
2876
|
}
|
|
2583
2877
|
function getNearestNativeShadowComponent(vm) {
|
|
2584
2878
|
const owner = getNearestShadowComponent(vm);
|
|
@@ -3161,6 +3455,28 @@
|
|
|
3161
3455
|
// in fallback mode, the allocation will always set children to
|
|
3162
3456
|
// empty and delegate the real allocation to the slot elements
|
|
3163
3457
|
allocateChildren(n2, vm);
|
|
3458
|
+
// Solves an edge case with slotted VFragments in native shadow mode.
|
|
3459
|
+
//
|
|
3460
|
+
// During allocation, in native shadow, slotted VFragment nodes are flattened and their text delimiters are removed
|
|
3461
|
+
// to avoid interfering with native slot behavior. When this happens, if any of the fragments
|
|
3462
|
+
// were not stable, the children must go through the dynamic diffing algo.
|
|
3463
|
+
//
|
|
3464
|
+
// If the new children (n2.children) contain no VFragments, but the previous children (n1.children) were dynamic,
|
|
3465
|
+
// the new nodes must be marked dynamic so that all nodes are properly updated. The only indicator that the new
|
|
3466
|
+
// nodes need to be dynamic comes from the previous children, so we check that to determine whether we need to
|
|
3467
|
+
// mark the new children dynamic.
|
|
3468
|
+
//
|
|
3469
|
+
// Example:
|
|
3470
|
+
// n1.children: [div, VFragment('', div, null, ''), div] => [div, div, null, div]; // marked dynamic
|
|
3471
|
+
// n2.children: [div, null, div] => [div, null, div] // marked ???
|
|
3472
|
+
const {
|
|
3473
|
+
shadowMode,
|
|
3474
|
+
renderMode
|
|
3475
|
+
} = vm;
|
|
3476
|
+
if (shadowMode == 0 /* ShadowMode.Native */ && renderMode !== 0 /* RenderMode.Light */ && hasDynamicChildren(n1.children)) {
|
|
3477
|
+
// No-op if children has already been marked dynamic by 'allocateChildren()'.
|
|
3478
|
+
markAsDynamicChildren(n2.children);
|
|
3479
|
+
}
|
|
3164
3480
|
}
|
|
3165
3481
|
// in fallback mode, the children will be always empty, so, nothing
|
|
3166
3482
|
// will happen, but in native, it does allocate the light dom
|
|
@@ -3322,20 +3638,65 @@
|
|
|
3322
3638
|
//
|
|
3323
3639
|
// In case #2, we will always get a fresh VCustomElement.
|
|
3324
3640
|
const children = vnode.aChildren || vnode.children;
|
|
3325
|
-
vm.aChildren = children;
|
|
3326
3641
|
const {
|
|
3327
3642
|
renderMode,
|
|
3328
3643
|
shadowMode
|
|
3329
3644
|
} = vm;
|
|
3645
|
+
// If any of the children being allocated are VFragments, we remove the text delimiters and flatten all immediate
|
|
3646
|
+
// children VFragments to avoid them interfering with default slot behavior.
|
|
3647
|
+
const allocatedChildren = flattenFragmentsInChildren(children);
|
|
3648
|
+
vnode.children = allocatedChildren;
|
|
3649
|
+
vm.aChildren = allocatedChildren;
|
|
3330
3650
|
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
3331
3651
|
// slow path
|
|
3332
|
-
allocateInSlot(vm,
|
|
3652
|
+
allocateInSlot(vm, allocatedChildren, vnode.owner);
|
|
3333
3653
|
// save the allocated children in case this vnode is reused.
|
|
3334
|
-
vnode.aChildren =
|
|
3654
|
+
vnode.aChildren = allocatedChildren;
|
|
3335
3655
|
// every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
3336
3656
|
vnode.children = EmptyArray;
|
|
3337
3657
|
}
|
|
3338
3658
|
}
|
|
3659
|
+
/**
|
|
3660
|
+
* Flattens the contents of all VFragments in an array of VNodes, removes the text delimiters on those VFragments, and
|
|
3661
|
+
* marks the resulting children array as dynamic. Uses a stack (array) to iteratively traverse the nested VFragments
|
|
3662
|
+
* and avoid the perf overhead of creating/destroying throwaway arrays/objects in a recursive approach.
|
|
3663
|
+
*
|
|
3664
|
+
* With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
|
|
3665
|
+
*
|
|
3666
|
+
* This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
|
|
3667
|
+
*/
|
|
3668
|
+
function flattenFragmentsInChildren(children) {
|
|
3669
|
+
const flattenedChildren = [];
|
|
3670
|
+
// Initialize our stack with the direct children of the custom component and check whether we have a VFragment.
|
|
3671
|
+
// If no VFragment is found in children, we don't need to traverse anything or mark the children dynamic and can return early.
|
|
3672
|
+
const nodeStack = [];
|
|
3673
|
+
let fragmentFound = false;
|
|
3674
|
+
for (let i = children.length - 1; i > -1; i -= 1) {
|
|
3675
|
+
const child = children[i];
|
|
3676
|
+
ArrayPush$1.call(nodeStack, child);
|
|
3677
|
+
fragmentFound = fragmentFound || !!(child && isVFragment(child));
|
|
3678
|
+
}
|
|
3679
|
+
if (!fragmentFound) {
|
|
3680
|
+
return children;
|
|
3681
|
+
}
|
|
3682
|
+
let currentNode;
|
|
3683
|
+
while (!isUndefined$1(currentNode = ArrayPop.call(nodeStack))) {
|
|
3684
|
+
if (!isNull(currentNode) && isVFragment(currentNode)) {
|
|
3685
|
+
const fChildren = currentNode.children;
|
|
3686
|
+
// Ignore the start and end text node delimiters
|
|
3687
|
+
for (let i = fChildren.length - 2; i > 0; i -= 1) {
|
|
3688
|
+
ArrayPush$1.call(nodeStack, fChildren[i]);
|
|
3689
|
+
}
|
|
3690
|
+
} else {
|
|
3691
|
+
ArrayPush$1.call(flattenedChildren, currentNode);
|
|
3692
|
+
}
|
|
3693
|
+
}
|
|
3694
|
+
// We always mark the children as dynamic because nothing generates stable VFragments yet.
|
|
3695
|
+
// If/when stable VFragments are generated by the compiler, this code should be updated to
|
|
3696
|
+
// not mark dynamic if all flattened VFragments were stable.
|
|
3697
|
+
markAsDynamicChildren(flattenedChildren);
|
|
3698
|
+
return flattenedChildren;
|
|
3699
|
+
}
|
|
3339
3700
|
function createViewModelHook(elm, vnode, renderer) {
|
|
3340
3701
|
let vm = getAssociatedVMIfPresent(elm);
|
|
3341
3702
|
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
@@ -3357,22 +3718,20 @@
|
|
|
3357
3718
|
});
|
|
3358
3719
|
return vm;
|
|
3359
3720
|
}
|
|
3360
|
-
|
|
3361
|
-
* Collects all slots into a SlotSet, traversing through VFragment Nodes
|
|
3362
|
-
*/
|
|
3363
|
-
function collectSlots(vm, children, cmpSlotsMapping) {
|
|
3721
|
+
function allocateInSlot(vm, children, owner) {
|
|
3364
3722
|
var _a, _b;
|
|
3723
|
+
const {
|
|
3724
|
+
cmpSlots: {
|
|
3725
|
+
slotAssignments: oldSlotsMapping
|
|
3726
|
+
}
|
|
3727
|
+
} = vm;
|
|
3728
|
+
const cmpSlotsMapping = create(null);
|
|
3729
|
+
// Collect all slots into cmpSlotsMapping
|
|
3365
3730
|
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
3366
3731
|
const vnode = children[i];
|
|
3367
3732
|
if (isNull(vnode)) {
|
|
3368
3733
|
continue;
|
|
3369
3734
|
}
|
|
3370
|
-
// Dive further iff the content is wrapped in a VFragment
|
|
3371
|
-
if (isVFragment(vnode)) {
|
|
3372
|
-
// Remove the text delimiter nodes to avoid overriding default slot content
|
|
3373
|
-
collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
|
|
3374
|
-
continue;
|
|
3375
|
-
}
|
|
3376
3735
|
let slotName = '';
|
|
3377
3736
|
if (isVBaseElement(vnode)) {
|
|
3378
3737
|
slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
|
|
@@ -3382,15 +3741,6 @@
|
|
|
3382
3741
|
const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
|
|
3383
3742
|
ArrayPush$1.call(vnodes, vnode);
|
|
3384
3743
|
}
|
|
3385
|
-
}
|
|
3386
|
-
function allocateInSlot(vm, children, owner) {
|
|
3387
|
-
const {
|
|
3388
|
-
cmpSlots: {
|
|
3389
|
-
slotAssignments: oldSlotsMapping
|
|
3390
|
-
}
|
|
3391
|
-
} = vm;
|
|
3392
|
-
const cmpSlotsMapping = create(null);
|
|
3393
|
-
collectSlots(vm, children, cmpSlotsMapping);
|
|
3394
3744
|
vm.cmpSlots = {
|
|
3395
3745
|
owner,
|
|
3396
3746
|
slotAssignments: cmpSlotsMapping
|
|
@@ -3421,14 +3771,14 @@
|
|
|
3421
3771
|
}
|
|
3422
3772
|
}
|
|
3423
3773
|
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
3424
|
-
const
|
|
3425
|
-
// dynamic children means it was generated by an iteration
|
|
3426
|
-
//
|
|
3774
|
+
const DynamicChildren = new WeakMap();
|
|
3775
|
+
// dynamic children means it was either generated by an iteration in a template
|
|
3776
|
+
// or part of an unstable fragment, and will require a more complex diffing algo.
|
|
3427
3777
|
function markAsDynamicChildren(children) {
|
|
3428
|
-
|
|
3778
|
+
DynamicChildren.set(children, 1);
|
|
3429
3779
|
}
|
|
3430
3780
|
function hasDynamicChildren(children) {
|
|
3431
|
-
return
|
|
3781
|
+
return DynamicChildren.has(children);
|
|
3432
3782
|
}
|
|
3433
3783
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
3434
3784
|
const map = {};
|
|
@@ -4087,7 +4437,7 @@
|
|
|
4087
4437
|
// Create a brand new template cache for the swapped templated.
|
|
4088
4438
|
context.tplCache = create(null);
|
|
4089
4439
|
// Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
|
|
4090
|
-
context.hasScopedStyles = computeHasScopedStyles(html);
|
|
4440
|
+
context.hasScopedStyles = computeHasScopedStyles(html, vm);
|
|
4091
4441
|
// Update the scoping token on the host element.
|
|
4092
4442
|
updateStylesheetToken(vm, html);
|
|
4093
4443
|
// Evaluate, create stylesheet and cache the produced VNode for future
|
|
@@ -4122,9 +4472,8 @@
|
|
|
4122
4472
|
});
|
|
4123
4473
|
return vnodes;
|
|
4124
4474
|
}
|
|
4125
|
-
function
|
|
4126
|
-
|
|
4127
|
-
if (!isUndefined$1(stylesheets)) {
|
|
4475
|
+
function computeHasScopedStylesInStylesheets(stylesheets) {
|
|
4476
|
+
if (hasStyles(stylesheets)) {
|
|
4128
4477
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4129
4478
|
if (isTrue(stylesheets[i][KEY__SCOPED_CSS])) {
|
|
4130
4479
|
return true;
|
|
@@ -4133,6 +4482,15 @@
|
|
|
4133
4482
|
}
|
|
4134
4483
|
return false;
|
|
4135
4484
|
}
|
|
4485
|
+
function computeHasScopedStyles(template, vm) {
|
|
4486
|
+
const { stylesheets } = template;
|
|
4487
|
+
const vmStylesheets = !isUndefined$1(vm) ? vm.stylesheets : null;
|
|
4488
|
+
return (computeHasScopedStylesInStylesheets(stylesheets) ||
|
|
4489
|
+
computeHasScopedStylesInStylesheets(vmStylesheets));
|
|
4490
|
+
}
|
|
4491
|
+
function hasStyles(stylesheets) {
|
|
4492
|
+
return !isUndefined$1(stylesheets) && !isNull(stylesheets) && stylesheets.length > 0;
|
|
4493
|
+
}
|
|
4136
4494
|
let vmBeingConstructed = null;
|
|
4137
4495
|
function isBeingConstructed(vm) {
|
|
4138
4496
|
return vmBeingConstructed === vm;
|
|
@@ -4409,6 +4767,7 @@
|
|
|
4409
4767
|
// Properties set right after VM creation.
|
|
4410
4768
|
tro: null,
|
|
4411
4769
|
shadowMode: null,
|
|
4770
|
+
stylesheets: null,
|
|
4412
4771
|
// Properties set by the LightningElement constructor.
|
|
4413
4772
|
component: null,
|
|
4414
4773
|
shadowRoot: null,
|
|
@@ -4418,6 +4777,7 @@
|
|
|
4418
4777
|
getHook,
|
|
4419
4778
|
renderer
|
|
4420
4779
|
};
|
|
4780
|
+
vm.stylesheets = computeStylesheets(vm, def.ctor);
|
|
4421
4781
|
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
4422
4782
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
4423
4783
|
// Create component instance associated to the vm and the element.
|
|
@@ -4428,6 +4788,40 @@
|
|
|
4428
4788
|
}
|
|
4429
4789
|
return vm;
|
|
4430
4790
|
}
|
|
4791
|
+
function validateComponentStylesheets(vm, stylesheets) {
|
|
4792
|
+
let valid = true;
|
|
4793
|
+
const validate = arrayOrStylesheet => {
|
|
4794
|
+
if (isArray$1(arrayOrStylesheet)) {
|
|
4795
|
+
for (let i = 0; i < arrayOrStylesheet.length; i++) {
|
|
4796
|
+
validate(arrayOrStylesheet[i]);
|
|
4797
|
+
}
|
|
4798
|
+
} else if (!isFunction$1(arrayOrStylesheet)) {
|
|
4799
|
+
// function assumed to be a stylesheet factory
|
|
4800
|
+
valid = false;
|
|
4801
|
+
}
|
|
4802
|
+
};
|
|
4803
|
+
if (!isArray$1(stylesheets)) {
|
|
4804
|
+
valid = false;
|
|
4805
|
+
} else {
|
|
4806
|
+
validate(stylesheets);
|
|
4807
|
+
}
|
|
4808
|
+
return valid;
|
|
4809
|
+
}
|
|
4810
|
+
// Validate and flatten any stylesheets defined as `static stylesheets`
|
|
4811
|
+
function computeStylesheets(vm, ctor) {
|
|
4812
|
+
if (lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
|
|
4813
|
+
const {
|
|
4814
|
+
stylesheets
|
|
4815
|
+
} = ctor;
|
|
4816
|
+
if (!isUndefined$1(stylesheets)) {
|
|
4817
|
+
const valid = validateComponentStylesheets(vm, stylesheets);
|
|
4818
|
+
if (valid) {
|
|
4819
|
+
return flattenStylesheets(stylesheets);
|
|
4820
|
+
}
|
|
4821
|
+
}
|
|
4822
|
+
}
|
|
4823
|
+
return null;
|
|
4824
|
+
}
|
|
4431
4825
|
function computeShadowMode(vm, renderer) {
|
|
4432
4826
|
const {
|
|
4433
4827
|
def
|
|
@@ -4760,262 +5154,134 @@
|
|
|
4760
5154
|
* SPDX-License-Identifier: MIT
|
|
4761
5155
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4762
5156
|
*/
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
updateComponentValue(vm, name, value);
|
|
4788
|
-
};
|
|
5157
|
+
//
|
|
5158
|
+
// The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
|
|
5159
|
+
// These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
|
|
5160
|
+
// When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
|
|
5161
|
+
// See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
|
|
5162
|
+
//
|
|
5163
|
+
// Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
|
|
5164
|
+
const getElementById = _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
|
|
5165
|
+
const querySelectorAll = _globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
|
|
5166
|
+
function isSyntheticShadowRootInstance(rootNode) {
|
|
5167
|
+
return rootNode !== document && isTrue(rootNode.synthetic);
|
|
5168
|
+
}
|
|
5169
|
+
function reportViolation(source, target, attrName) {
|
|
5170
|
+
// The vm is either for the source, the target, or both. Either one or both must be using synthetic
|
|
5171
|
+
// shadow for a violation to be detected.
|
|
5172
|
+
let vm = getAssociatedVMIfPresent(source.getRootNode().host);
|
|
5173
|
+
if (isUndefined$1(vm)) {
|
|
5174
|
+
vm = getAssociatedVMIfPresent(target.getRootNode().host);
|
|
5175
|
+
}
|
|
5176
|
+
if (isUndefined$1(vm)) {
|
|
5177
|
+
// vm should never be undefined here, but just to be safe, bail out and don't report
|
|
5178
|
+
return;
|
|
5179
|
+
}
|
|
5180
|
+
report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
|
|
4789
5181
|
}
|
|
4790
|
-
function
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
runWithBoundaryProtection(vm, vm.owner, noop, () => {
|
|
4794
|
-
// job
|
|
4795
|
-
method.call(vm.component, value);
|
|
4796
|
-
}, noop);
|
|
4797
|
-
};
|
|
5182
|
+
function parseIdRefAttributeValue(attrValue) {
|
|
5183
|
+
// split on whitespace and skip empty strings after splitting
|
|
5184
|
+
return isString(attrValue) ? ArrayFilter.call(StringSplit.call(attrValue, /\s+/), Boolean) : [];
|
|
4798
5185
|
}
|
|
4799
|
-
function
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
if (hasPendingConfig === false) {
|
|
4804
|
-
hasPendingConfig = true;
|
|
4805
|
-
// collect new config in the micro-task
|
|
4806
|
-
Promise.resolve().then(() => {
|
|
4807
|
-
hasPendingConfig = false;
|
|
4808
|
-
// resetting current reactive params
|
|
4809
|
-
ro.reset();
|
|
4810
|
-
// dispatching a new config due to a change in the configuration
|
|
4811
|
-
computeConfigAndUpdate();
|
|
4812
|
-
});
|
|
5186
|
+
function detectSyntheticCrossRootAria(elm, attrName, attrValue) {
|
|
5187
|
+
const root = elm.getRootNode();
|
|
5188
|
+
if (!isSyntheticShadowRootInstance(root)) {
|
|
5189
|
+
return;
|
|
4813
5190
|
}
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
return; // no provider found, nothing to be done
|
|
4835
|
-
}
|
|
4836
|
-
|
|
4837
|
-
const {
|
|
4838
|
-
elm,
|
|
4839
|
-
context: {
|
|
4840
|
-
wiredConnecting,
|
|
4841
|
-
wiredDisconnecting
|
|
4842
|
-
},
|
|
4843
|
-
renderer: {
|
|
4844
|
-
dispatchEvent
|
|
5191
|
+
if (attrName === 'id') {
|
|
5192
|
+
// elm is the target, find the source
|
|
5193
|
+
if (!isString(attrValue) || attrValue.length === 0) {
|
|
5194
|
+
// if our id is null or empty, nobody can reference us
|
|
5195
|
+
return;
|
|
5196
|
+
}
|
|
5197
|
+
for (const idRefAttrName of ID_REFERENCING_ATTRIBUTES_SET) {
|
|
5198
|
+
// Query all global elements with this attribute. The attribute selector syntax `~=` is for values
|
|
5199
|
+
// that reference multiple IDs, separated by whitespace.
|
|
5200
|
+
const query = `[${idRefAttrName}~="${CSS.escape(attrValue)}"]`;
|
|
5201
|
+
const sourceElements = querySelectorAll.call(document, query);
|
|
5202
|
+
for (let i = 0; i < sourceElements.length; i++) {
|
|
5203
|
+
const sourceElement = sourceElements[i];
|
|
5204
|
+
const sourceRoot = sourceElement.getRootNode();
|
|
5205
|
+
if (sourceRoot !== root) {
|
|
5206
|
+
reportViolation(sourceElement, elm);
|
|
5207
|
+
break;
|
|
5208
|
+
}
|
|
5209
|
+
}
|
|
5210
|
+
}
|
|
4845
5211
|
}
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
callbackWhenContextIsReady(newContext);
|
|
4859
|
-
},
|
|
4860
|
-
setDisconnectedCallback(disconnectCallback) {
|
|
4861
|
-
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
4862
|
-
// the the element hosting the wire is disconnected
|
|
4863
|
-
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
4864
|
-
}
|
|
4865
|
-
});
|
|
4866
|
-
dispatchEvent(elm, contextRegistrationEvent);
|
|
4867
|
-
});
|
|
4868
|
-
}
|
|
4869
|
-
function createConnector(vm, name, wireDef) {
|
|
4870
|
-
const {
|
|
4871
|
-
method,
|
|
4872
|
-
adapter,
|
|
4873
|
-
configCallback,
|
|
4874
|
-
dynamic
|
|
4875
|
-
} = wireDef;
|
|
4876
|
-
let debugInfo;
|
|
4877
|
-
const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
4878
|
-
const dataCallback = value => {
|
|
4879
|
-
fieldOrMethodCallback(value);
|
|
4880
|
-
};
|
|
4881
|
-
let context;
|
|
4882
|
-
let connector;
|
|
4883
|
-
// Workaround to pass the component element associated to this wire adapter instance.
|
|
4884
|
-
defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
4885
|
-
value: vm.elm
|
|
4886
|
-
});
|
|
4887
|
-
defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
|
|
4888
|
-
value: dynamic
|
|
4889
|
-
});
|
|
4890
|
-
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
4891
|
-
// job
|
|
4892
|
-
connector = new adapter(dataCallback);
|
|
4893
|
-
}, noop);
|
|
4894
|
-
const updateConnectorConfig = config => {
|
|
4895
|
-
// every time the config is recomputed due to tracking,
|
|
4896
|
-
// this callback will be invoked with the new computed config
|
|
4897
|
-
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
4898
|
-
// job
|
|
4899
|
-
if ("production" !== 'production') ;
|
|
4900
|
-
connector.update(config, context);
|
|
4901
|
-
}, noop);
|
|
4902
|
-
};
|
|
4903
|
-
// Computes the current wire config and calls the update method on the wire adapter.
|
|
4904
|
-
// If it has params, we will need to observe changes in the next tick.
|
|
4905
|
-
const {
|
|
4906
|
-
computeConfigAndUpdate,
|
|
4907
|
-
ro
|
|
4908
|
-
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
4909
|
-
// if the adapter needs contextualization, we need to watch for new context and push it alongside the config
|
|
4910
|
-
if (!isUndefined$1(adapter.contextSchema)) {
|
|
4911
|
-
createContextWatcher(vm, wireDef, newContext => {
|
|
4912
|
-
// every time the context is pushed into this component,
|
|
4913
|
-
// this callback will be invoked with the new computed context
|
|
4914
|
-
if (context !== newContext) {
|
|
4915
|
-
context = newContext;
|
|
4916
|
-
// Note: when new context arrives, the config will be recomputed and pushed along side the new
|
|
4917
|
-
// context, this is to preserve the identity characteristics, config should not have identity
|
|
4918
|
-
// (ever), while context can have identity
|
|
4919
|
-
if (vm.state === 1 /* VMState.connected */) {
|
|
4920
|
-
computeConfigAndUpdate();
|
|
5212
|
+
else {
|
|
5213
|
+
// elm is the source, find the target
|
|
5214
|
+
const ids = parseIdRefAttributeValue(attrValue);
|
|
5215
|
+
for (const id of ids) {
|
|
5216
|
+
const target = getElementById.call(document, id);
|
|
5217
|
+
if (!isNull(target)) {
|
|
5218
|
+
const targetRoot = target.getRootNode();
|
|
5219
|
+
if (targetRoot !== root) {
|
|
5220
|
+
// target element's shadow root is not the same as ours
|
|
5221
|
+
reportViolation(elm, target);
|
|
5222
|
+
}
|
|
5223
|
+
}
|
|
4921
5224
|
}
|
|
4922
|
-
}
|
|
4923
|
-
});
|
|
4924
|
-
}
|
|
4925
|
-
return {
|
|
4926
|
-
// @ts-ignore the boundary protection executes sync, connector is always defined
|
|
4927
|
-
connector,
|
|
4928
|
-
computeConfigAndUpdate,
|
|
4929
|
-
resetConfigWatcher: () => ro.reset()
|
|
4930
|
-
};
|
|
4931
|
-
}
|
|
4932
|
-
const AdapterToTokenMap = new Map();
|
|
4933
|
-
function getAdapterToken(adapter) {
|
|
4934
|
-
return AdapterToTokenMap.get(adapter);
|
|
4935
|
-
}
|
|
4936
|
-
function setAdapterToken(adapter, token) {
|
|
4937
|
-
AdapterToTokenMap.set(adapter, token);
|
|
4938
|
-
}
|
|
4939
|
-
function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
|
|
4940
|
-
// support for callable adapters
|
|
4941
|
-
if (adapter.adapter) {
|
|
4942
|
-
adapter = adapter.adapter;
|
|
4943
|
-
}
|
|
4944
|
-
const method = descriptor.value;
|
|
4945
|
-
const def = {
|
|
4946
|
-
adapter,
|
|
4947
|
-
method,
|
|
4948
|
-
configCallback,
|
|
4949
|
-
dynamic
|
|
4950
|
-
};
|
|
4951
|
-
WireMetaMap.set(descriptor, def);
|
|
4952
|
-
}
|
|
4953
|
-
function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
|
|
4954
|
-
// support for callable adapters
|
|
4955
|
-
if (adapter.adapter) {
|
|
4956
|
-
adapter = adapter.adapter;
|
|
4957
|
-
}
|
|
4958
|
-
const def = {
|
|
4959
|
-
adapter,
|
|
4960
|
-
configCallback,
|
|
4961
|
-
dynamic
|
|
4962
|
-
};
|
|
4963
|
-
WireMetaMap.set(descriptor, def);
|
|
4964
|
-
}
|
|
4965
|
-
function installWireAdapters(vm) {
|
|
4966
|
-
const {
|
|
4967
|
-
context,
|
|
4968
|
-
def: {
|
|
4969
|
-
wire
|
|
4970
5225
|
}
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
5226
|
+
}
|
|
5227
|
+
let enabled = false;
|
|
5228
|
+
// We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
|
|
5229
|
+
// reporting is not enabled. It should also only run once
|
|
5230
|
+
function enableDetection() {
|
|
5231
|
+
if (enabled) {
|
|
5232
|
+
return; // don't double-apply the patches
|
|
5233
|
+
}
|
|
5234
|
+
enabled = true;
|
|
5235
|
+
const { setAttribute } = Element.prototype;
|
|
5236
|
+
// Detect calling `setAttribute` to set an idref or an id
|
|
5237
|
+
assign(Element.prototype, {
|
|
5238
|
+
setAttribute(attrName, attrValue) {
|
|
5239
|
+
setAttribute.call(this, attrName, attrValue);
|
|
5240
|
+
if (attrName === 'id' || ID_REFERENCING_ATTRIBUTES_SET.has(attrName)) {
|
|
5241
|
+
detectSyntheticCrossRootAria(this, attrName, attrValue);
|
|
5242
|
+
}
|
|
5243
|
+
},
|
|
5244
|
+
});
|
|
5245
|
+
// Detect `elm.id = 'foo'`
|
|
5246
|
+
const idDescriptor = getOwnPropertyDescriptor$1(Element.prototype, 'id');
|
|
5247
|
+
if (!isUndefined$1(idDescriptor)) {
|
|
5248
|
+
const { get, set } = idDescriptor;
|
|
5249
|
+
// These should always be a getter and a setter, but if someone is monkeying with the global descriptor, ignore it
|
|
5250
|
+
if (isFunction$1(get) && isFunction$1(set)) {
|
|
5251
|
+
defineProperty(Element.prototype, 'id', {
|
|
5252
|
+
get() {
|
|
5253
|
+
return get.call(this);
|
|
5254
|
+
},
|
|
5255
|
+
set(value) {
|
|
5256
|
+
set.call(this, value);
|
|
5257
|
+
detectSyntheticCrossRootAria(this, 'id', value);
|
|
5258
|
+
},
|
|
5259
|
+
// On the default descriptor for 'id', enumerable and configurable are true
|
|
5260
|
+
enumerable: true,
|
|
5261
|
+
configurable: true,
|
|
5262
|
+
});
|
|
4991
5263
|
}
|
|
4992
|
-
computeConfigAndUpdate();
|
|
4993
|
-
});
|
|
4994
|
-
ArrayPush$1.call(wiredDisconnecting, () => {
|
|
4995
|
-
connector.disconnect();
|
|
4996
|
-
resetConfigWatcher();
|
|
4997
|
-
});
|
|
4998
5264
|
}
|
|
4999
|
-
}
|
|
5000
5265
|
}
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
|
5006
|
-
wiredConnecting[i]();
|
|
5007
|
-
}
|
|
5266
|
+
// Our detection logic relies on some modern browser features. We can just skip reporting the data
|
|
5267
|
+
// for unsupported browsers
|
|
5268
|
+
function supportsCssEscape() {
|
|
5269
|
+
return typeof CSS !== 'undefined' && isFunction$1(CSS.escape);
|
|
5008
5270
|
}
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5271
|
+
// If this page is not using synthetic shadow, then we don't need to install detection. Note
|
|
5272
|
+
// that we are assuming synthetic shadow is loaded before LWC.
|
|
5273
|
+
function isSyntheticShadowLoaded() {
|
|
5274
|
+
// We should probably be calling `renderer.isSyntheticShadowDefined`, but 1) we don't have access to the renderer,
|
|
5275
|
+
// and 2) this code needs to run in @lwc/engine-core, so it can access `logWarn()` and `report()`.
|
|
5276
|
+
return hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
|
|
5277
|
+
}
|
|
5278
|
+
// Detecting cross-root ARIA in synthetic shadow only makes sense for the browser
|
|
5279
|
+
if (supportsCssEscape() && isSyntheticShadowLoaded()) {
|
|
5280
|
+
// Always run detection in dev mode, so we can at least print to the console
|
|
5281
|
+
{
|
|
5282
|
+
// In prod mode, only enable detection if reporting is enabled
|
|
5283
|
+
onReportingEnabled(enableDetection);
|
|
5017
5284
|
}
|
|
5018
|
-
}, noop);
|
|
5019
5285
|
}
|
|
5020
5286
|
|
|
5021
5287
|
/*
|
|
@@ -6383,7 +6649,7 @@
|
|
|
6383
6649
|
function isNull(obj) {
|
|
6384
6650
|
return obj === null;
|
|
6385
6651
|
}
|
|
6386
|
-
/** version: 2.
|
|
6652
|
+
/** version: 2.35.0 */
|
|
6387
6653
|
|
|
6388
6654
|
/*
|
|
6389
6655
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6936,10 +7202,11 @@
|
|
|
6936
7202
|
});
|
|
6937
7203
|
freeze(LightningElement);
|
|
6938
7204
|
seal(LightningElement.prototype);
|
|
6939
|
-
/* version: 2.
|
|
7205
|
+
/* version: 2.35.0 */
|
|
6940
7206
|
|
|
6941
7207
|
exports.LightningElement = LightningElement;
|
|
6942
7208
|
exports.__unstable__ProfilerControl = profilerControl;
|
|
7209
|
+
exports.__unstable__ReportingControl = reportingControl;
|
|
6943
7210
|
exports.api = api$1;
|
|
6944
7211
|
exports.buildCustomElementConstructor = deprecatedBuildCustomElementConstructor;
|
|
6945
7212
|
exports.createContextProvider = createContextProvider;
|