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
|
@@ -45,7 +45,7 @@ const { assign, create, defineProperties, defineProperty, freeze, getOwnProperty
|
|
|
45
45
|
const { isArray: isArray$1 } = Array;
|
|
46
46
|
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;
|
|
47
47
|
const { fromCharCode: StringFromCharCode } = String;
|
|
48
|
-
const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
|
|
48
|
+
const { charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
|
|
49
49
|
function isUndefined$1(obj) {
|
|
50
50
|
return obj === undefined;
|
|
51
51
|
}
|
|
@@ -182,6 +182,19 @@ const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (
|
|
|
182
182
|
});
|
|
183
183
|
return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap };
|
|
184
184
|
})();
|
|
185
|
+
// These attributes take either an ID or a list of IDs as values.
|
|
186
|
+
// This includes aria-* attributes as well as the special non-ARIA "for" attribute
|
|
187
|
+
const ID_REFERENCING_ATTRIBUTES_SET = new Set([
|
|
188
|
+
'aria-activedescendant',
|
|
189
|
+
'aria-controls',
|
|
190
|
+
'aria-describedby',
|
|
191
|
+
'aria-details',
|
|
192
|
+
'aria-errormessage',
|
|
193
|
+
'aria-flowto',
|
|
194
|
+
'aria-labelledby',
|
|
195
|
+
'aria-owns',
|
|
196
|
+
'for',
|
|
197
|
+
]);
|
|
185
198
|
|
|
186
199
|
/*
|
|
187
200
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -237,6 +250,8 @@ const KEY__SHADOW_STATIC = '$shadowStaticNode$';
|
|
|
237
250
|
const KEY__SHADOW_TOKEN = '$shadowToken$';
|
|
238
251
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
|
239
252
|
const KEY__SCOPED_CSS = '$scoped$';
|
|
253
|
+
const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
|
|
254
|
+
const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
|
240
255
|
const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
241
256
|
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
242
257
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
@@ -344,9 +359,9 @@ function htmlAttributeToProperty(attrName) {
|
|
|
344
359
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
345
360
|
*/
|
|
346
361
|
// Increment whenever the LWC template compiler changes
|
|
347
|
-
const LWC_VERSION = "2.
|
|
362
|
+
const LWC_VERSION = "2.35.0";
|
|
348
363
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
349
|
-
/** version: 2.
|
|
364
|
+
/** version: 2.35.0 */
|
|
350
365
|
|
|
351
366
|
/**
|
|
352
367
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -369,6 +384,7 @@ const features = {
|
|
|
369
384
|
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
370
385
|
ENABLE_FROZEN_TEMPLATE: null,
|
|
371
386
|
DISABLE_ARIA_REFLECTION_POLYFILL: null,
|
|
387
|
+
ENABLE_PROGRAMMATIC_STYLESHEETS: null,
|
|
372
388
|
};
|
|
373
389
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
374
390
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -422,7 +438,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
422
438
|
setFeatureFlag(name, value);
|
|
423
439
|
}
|
|
424
440
|
}
|
|
425
|
-
/** version: 2.
|
|
441
|
+
/** version: 2.35.0 */
|
|
426
442
|
|
|
427
443
|
/**
|
|
428
444
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -486,7 +502,7 @@ function applyAriaReflection(prototype = Element.prototype) {
|
|
|
486
502
|
}
|
|
487
503
|
}
|
|
488
504
|
}
|
|
489
|
-
/** version: 2.
|
|
505
|
+
/** version: 2.35.0 */
|
|
490
506
|
|
|
491
507
|
/*
|
|
492
508
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -554,94 +570,167 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
|
554
570
|
* SPDX-License-Identifier: MIT
|
|
555
571
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
556
572
|
*/
|
|
557
|
-
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
573
|
+
/** Callbacks to invoke when reporting is enabled **/
|
|
574
|
+
const onReportingEnabledCallbacks = [];
|
|
575
|
+
/** The currently assigned reporting dispatcher. */
|
|
576
|
+
let currentDispatcher$1 = noop;
|
|
577
|
+
/**
|
|
578
|
+
* Whether reporting is enabled.
|
|
579
|
+
*
|
|
580
|
+
* Note that this may seem redundant, given you can just check if the currentDispatcher is undefined,
|
|
581
|
+
* but it turns out that Terser only strips out unused code if we use this explicit boolean.
|
|
582
|
+
*/
|
|
583
|
+
let enabled$1 = false;
|
|
584
|
+
const reportingControl = {
|
|
585
|
+
/**
|
|
586
|
+
* Attach a new reporting control (aka dispatcher).
|
|
587
|
+
*
|
|
588
|
+
* @param dispatcher - reporting control
|
|
589
|
+
*/
|
|
590
|
+
attachDispatcher(dispatcher) {
|
|
591
|
+
enabled$1 = true;
|
|
592
|
+
currentDispatcher$1 = dispatcher;
|
|
593
|
+
for (const callback of onReportingEnabledCallbacks) {
|
|
594
|
+
try {
|
|
595
|
+
callback();
|
|
596
|
+
}
|
|
597
|
+
catch (err) {
|
|
598
|
+
// This should never happen. But if it does, we don't want one callback to cause another to fail
|
|
599
|
+
// eslint-disable-next-line no-console
|
|
600
|
+
console.error('Could not invoke callback', err);
|
|
601
|
+
}
|
|
565
602
|
}
|
|
603
|
+
onReportingEnabledCallbacks.length = 0; // clear the array
|
|
604
|
+
},
|
|
605
|
+
/**
|
|
606
|
+
* Detach the current reporting control (aka dispatcher).
|
|
607
|
+
*/
|
|
608
|
+
detachDispatcher() {
|
|
609
|
+
enabled$1 = false;
|
|
610
|
+
currentDispatcher$1 = noop;
|
|
611
|
+
},
|
|
612
|
+
};
|
|
613
|
+
/**
|
|
614
|
+
* Call a callback when reporting is enabled, or immediately if reporting is already enabled.
|
|
615
|
+
* Will only ever be called once.
|
|
616
|
+
* @param callback
|
|
617
|
+
*/
|
|
618
|
+
function onReportingEnabled(callback) {
|
|
619
|
+
if (enabled$1) {
|
|
620
|
+
// call immediately
|
|
621
|
+
callback();
|
|
566
622
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
callbacks[i]();
|
|
623
|
+
else {
|
|
624
|
+
// call later
|
|
625
|
+
onReportingEnabledCallbacks.push(callback);
|
|
571
626
|
}
|
|
572
627
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
if (
|
|
580
|
-
|
|
628
|
+
/**
|
|
629
|
+
* Report to the current dispatcher, if there is one.
|
|
630
|
+
* @param reportingEventId
|
|
631
|
+
* @param vm
|
|
632
|
+
*/
|
|
633
|
+
function report(reportingEventId, vm) {
|
|
634
|
+
if (enabled$1) {
|
|
635
|
+
currentDispatcher$1(reportingEventId, vm.tagName, vm.idx);
|
|
581
636
|
}
|
|
582
|
-
ArrayPush$1.call(nextTickCallbackQueue, callback);
|
|
583
637
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
638
|
+
|
|
639
|
+
/*
|
|
640
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
641
|
+
* All rights reserved.
|
|
642
|
+
* SPDX-License-Identifier: MIT
|
|
643
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
644
|
+
*/
|
|
645
|
+
function getComponentTag(vm) {
|
|
646
|
+
return `<${StringToLowerCase.call(vm.tagName)}>`;
|
|
647
|
+
}
|
|
648
|
+
// TODO [#1695]: Unify getComponentStack and getErrorComponentStack
|
|
649
|
+
function getComponentStack(vm) {
|
|
650
|
+
const stack = [];
|
|
651
|
+
let prefix = '';
|
|
652
|
+
while (!isNull(vm.owner)) {
|
|
653
|
+
ArrayPush$1.call(stack, prefix + getComponentTag(vm));
|
|
654
|
+
vm = vm.owner;
|
|
655
|
+
prefix += '\t';
|
|
589
656
|
}
|
|
590
|
-
return
|
|
657
|
+
return ArrayJoin.call(stack, '\n');
|
|
591
658
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
const declarations = cssText.split(DECLARATION_DELIMITER);
|
|
599
|
-
for (const declaration of declarations) {
|
|
600
|
-
if (declaration) {
|
|
601
|
-
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
|
602
|
-
if (prop !== undefined && value !== undefined) {
|
|
603
|
-
styleMap[prop.trim()] = value.trim();
|
|
604
|
-
}
|
|
605
|
-
}
|
|
659
|
+
function getErrorComponentStack(vm) {
|
|
660
|
+
const wcStack = [];
|
|
661
|
+
let currentVm = vm;
|
|
662
|
+
while (!isNull(currentVm)) {
|
|
663
|
+
ArrayPush$1.call(wcStack, getComponentTag(currentVm));
|
|
664
|
+
currentVm = currentVm.owner;
|
|
606
665
|
}
|
|
607
|
-
return
|
|
666
|
+
return wcStack.reverse().join('\n\t');
|
|
608
667
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
668
|
+
|
|
669
|
+
/*
|
|
670
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
671
|
+
* All rights reserved.
|
|
672
|
+
* SPDX-License-Identifier: MIT
|
|
673
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
674
|
+
*/
|
|
675
|
+
function addErrorComponentStack(vm, error) {
|
|
676
|
+
if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
|
|
677
|
+
const wcStack = getErrorComponentStack(vm);
|
|
678
|
+
defineProperty(error, 'wcStack', {
|
|
679
|
+
get() {
|
|
680
|
+
return wcStack;
|
|
681
|
+
},
|
|
682
|
+
});
|
|
616
683
|
}
|
|
617
|
-
return result;
|
|
618
684
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
685
|
+
|
|
686
|
+
/*
|
|
687
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
688
|
+
* All rights reserved.
|
|
689
|
+
* SPDX-License-Identifier: MIT
|
|
690
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
691
|
+
*/
|
|
692
|
+
const alreadyLoggedMessages = new Set();
|
|
693
|
+
// @ts-ignore
|
|
694
|
+
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
695
|
+
// @ts-ignore
|
|
696
|
+
window.__lwcResetAlreadyLoggedMessages = () => {
|
|
697
|
+
alreadyLoggedMessages.clear();
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
function log(method, message, vm, once) {
|
|
701
|
+
let msg = `[LWC ${method}]: ${message}`;
|
|
702
|
+
if (!isUndefined$1(vm)) {
|
|
703
|
+
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
704
|
+
}
|
|
705
|
+
if (once) {
|
|
706
|
+
if (alreadyLoggedMessages.has(msg)) {
|
|
707
|
+
return;
|
|
627
708
|
}
|
|
709
|
+
alreadyLoggedMessages.add(msg);
|
|
628
710
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
throw new Error('refVNodes must be defined when setting a ref');
|
|
711
|
+
// In Jest tests, reduce the warning and error verbosity by not printing the callstack
|
|
712
|
+
if (process.env.NODE_ENV === 'test') {
|
|
713
|
+
/* eslint-disable-next-line no-console */
|
|
714
|
+
console[method](msg);
|
|
715
|
+
return;
|
|
635
716
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
refVNodes[ref] = vnode;
|
|
717
|
+
try {
|
|
718
|
+
throw new Error(msg);
|
|
719
|
+
}
|
|
720
|
+
catch (e) {
|
|
721
|
+
/* eslint-disable-next-line no-console */
|
|
722
|
+
console[method](e);
|
|
643
723
|
}
|
|
644
724
|
}
|
|
725
|
+
function logError(message, vm) {
|
|
726
|
+
log('error', message, vm, false);
|
|
727
|
+
}
|
|
728
|
+
function logWarn(message, vm) {
|
|
729
|
+
log('warn', message, vm, false);
|
|
730
|
+
}
|
|
731
|
+
function logWarnOnce(message, vm) {
|
|
732
|
+
log('warn', message, vm, true);
|
|
733
|
+
}
|
|
645
734
|
|
|
646
735
|
/*
|
|
647
736
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
@@ -763,80 +852,97 @@ function createReactiveObserver(callback) {
|
|
|
763
852
|
* SPDX-License-Identifier: MIT
|
|
764
853
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
765
854
|
*/
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
function
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
vm = vm.owner;
|
|
776
|
-
prefix += '\t';
|
|
777
|
-
}
|
|
778
|
-
return ArrayJoin.call(stack, '\n');
|
|
779
|
-
}
|
|
780
|
-
function getErrorComponentStack(vm) {
|
|
781
|
-
const wcStack = [];
|
|
782
|
-
let currentVm = vm;
|
|
783
|
-
while (!isNull(currentVm)) {
|
|
784
|
-
ArrayPush$1.call(wcStack, getComponentTag(currentVm));
|
|
785
|
-
currentVm = currentVm.owner;
|
|
855
|
+
let nextTickCallbackQueue = [];
|
|
856
|
+
const SPACE_CHAR = 32;
|
|
857
|
+
const EmptyObject = seal(create(null));
|
|
858
|
+
const EmptyArray = seal([]);
|
|
859
|
+
function flushCallbackQueue() {
|
|
860
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
861
|
+
if (nextTickCallbackQueue.length === 0) {
|
|
862
|
+
throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
|
|
863
|
+
}
|
|
786
864
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
792
|
-
* All rights reserved.
|
|
793
|
-
* SPDX-License-Identifier: MIT
|
|
794
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
795
|
-
*/
|
|
796
|
-
function addErrorComponentStack(vm, error) {
|
|
797
|
-
if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
|
|
798
|
-
const wcStack = getErrorComponentStack(vm);
|
|
799
|
-
defineProperty(error, 'wcStack', {
|
|
800
|
-
get() {
|
|
801
|
-
return wcStack;
|
|
802
|
-
},
|
|
803
|
-
});
|
|
865
|
+
const callbacks = nextTickCallbackQueue;
|
|
866
|
+
nextTickCallbackQueue = []; // reset to a new queue
|
|
867
|
+
for (let i = 0, len = callbacks.length; i < len; i += 1) {
|
|
868
|
+
callbacks[i]();
|
|
804
869
|
}
|
|
805
870
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
812
|
-
*/
|
|
813
|
-
function log(method, message, vm) {
|
|
814
|
-
let msg = `[LWC ${method}]: ${message}`;
|
|
815
|
-
if (!isUndefined$1(vm)) {
|
|
816
|
-
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
817
|
-
}
|
|
818
|
-
if (process.env.NODE_ENV === 'test') {
|
|
819
|
-
/* eslint-disable-next-line no-console */
|
|
820
|
-
console[method](msg);
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
try {
|
|
824
|
-
throw new Error(msg);
|
|
871
|
+
function addCallbackToNextTick(callback) {
|
|
872
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
873
|
+
if (!isFunction$1(callback)) {
|
|
874
|
+
throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
|
|
875
|
+
}
|
|
825
876
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
console[method](e);
|
|
877
|
+
if (nextTickCallbackQueue.length === 0) {
|
|
878
|
+
Promise.resolve().then(flushCallbackQueue);
|
|
829
879
|
}
|
|
880
|
+
ArrayPush$1.call(nextTickCallbackQueue, callback);
|
|
830
881
|
}
|
|
831
|
-
function
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
882
|
+
function guid() {
|
|
883
|
+
function s4() {
|
|
884
|
+
return Math.floor((1 + Math.random()) * 0x10000)
|
|
885
|
+
.toString(16)
|
|
886
|
+
.substring(1);
|
|
887
|
+
}
|
|
888
|
+
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
836
889
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
890
|
+
// Borrowed from Vue template compiler.
|
|
891
|
+
// https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
|
|
892
|
+
const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
|
|
893
|
+
const PROPERTY_DELIMITER = /:(.+)/;
|
|
894
|
+
function parseStyleText(cssText) {
|
|
895
|
+
const styleMap = {};
|
|
896
|
+
const declarations = cssText.split(DECLARATION_DELIMITER);
|
|
897
|
+
for (const declaration of declarations) {
|
|
898
|
+
if (declaration) {
|
|
899
|
+
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
|
900
|
+
if (prop !== undefined && value !== undefined) {
|
|
901
|
+
styleMap[prop.trim()] = value.trim();
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
return styleMap;
|
|
906
|
+
}
|
|
907
|
+
// Make a shallow copy of an object but omit the given key
|
|
908
|
+
function cloneAndOmitKey(object, keyToOmit) {
|
|
909
|
+
const result = {};
|
|
910
|
+
for (const key of Object.keys(object)) {
|
|
911
|
+
if (key !== keyToOmit) {
|
|
912
|
+
result[key] = object[key];
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
return result;
|
|
916
|
+
}
|
|
917
|
+
function flattenStylesheets(stylesheets) {
|
|
918
|
+
const list = [];
|
|
919
|
+
for (const stylesheet of stylesheets) {
|
|
920
|
+
if (!Array.isArray(stylesheet)) {
|
|
921
|
+
list.push(stylesheet);
|
|
922
|
+
}
|
|
923
|
+
else {
|
|
924
|
+
list.push(...flattenStylesheets(stylesheet));
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return list;
|
|
928
|
+
}
|
|
929
|
+
// Set a ref (lwc:ref) on a VM, from a template API
|
|
930
|
+
function setRefVNode(vm, ref, vnode) {
|
|
931
|
+
if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
|
|
932
|
+
throw new Error('refVNodes must be defined when setting a ref');
|
|
933
|
+
}
|
|
934
|
+
// If this method is called, then vm.refVNodes is set as the template has refs.
|
|
935
|
+
// If not, then something went wrong and we threw an error above.
|
|
936
|
+
const refVNodes = vm.refVNodes;
|
|
937
|
+
// In cases of conflict (two elements with the same ref), prefer, the last one,
|
|
938
|
+
// in depth-first traversal order.
|
|
939
|
+
if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
|
|
940
|
+
refVNodes[ref] = vnode;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/*
|
|
945
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
840
946
|
* All rights reserved.
|
|
841
947
|
* SPDX-License-Identifier: MIT
|
|
842
948
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
@@ -884,7 +990,10 @@ function offsetPropertyErrorMessage(name) {
|
|
|
884
990
|
// Global HTML Attributes & Properties
|
|
885
991
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
|
|
886
992
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
|
|
887
|
-
|
|
993
|
+
//
|
|
994
|
+
// If you update this list, check for test files that recapitulate the same list. Searching the codebase
|
|
995
|
+
// for e.g. "dropzone" should suffice.
|
|
996
|
+
const globalHTMLProperties = {
|
|
888
997
|
accessKey: {
|
|
889
998
|
attribute: 'accesskey',
|
|
890
999
|
},
|
|
@@ -969,7 +1078,7 @@ const globalHTMLProperties = assign(create(null), {
|
|
|
969
1078
|
role: {
|
|
970
1079
|
attribute: 'role',
|
|
971
1080
|
},
|
|
972
|
-
}
|
|
1081
|
+
};
|
|
973
1082
|
let controlledElement = null;
|
|
974
1083
|
let controlledAttributeName;
|
|
975
1084
|
function isAttributeLocked(elm, attrName) {
|
|
@@ -2431,89 +2540,377 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
2431
2540
|
* SPDX-License-Identifier: MIT
|
|
2432
2541
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2433
2542
|
*/
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2543
|
+
const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
|
|
2544
|
+
const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
|
2545
|
+
const WIRE_DEBUG_ENTRY = '@wire';
|
|
2546
|
+
const WireMetaMap = new Map();
|
|
2547
|
+
class WireContextRegistrationEvent extends CustomEvent {
|
|
2548
|
+
constructor(adapterToken, {
|
|
2549
|
+
setNewContext,
|
|
2550
|
+
setDisconnectedCallback
|
|
2551
|
+
}) {
|
|
2552
|
+
super(adapterToken, {
|
|
2553
|
+
bubbles: true,
|
|
2554
|
+
composed: true
|
|
2555
|
+
});
|
|
2556
|
+
defineProperties(this, {
|
|
2557
|
+
setNewContext: {
|
|
2558
|
+
value: setNewContext
|
|
2559
|
+
},
|
|
2560
|
+
setDisconnectedCallback: {
|
|
2561
|
+
value: setDisconnectedCallback
|
|
2562
|
+
}
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2439
2565
|
}
|
|
2440
|
-
function
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
if (isBeingConstructed(vm)) {
|
|
2445
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2446
|
-
logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
2447
|
-
}
|
|
2448
|
-
return;
|
|
2449
|
-
}
|
|
2450
|
-
componentValueObserved(vm, key);
|
|
2451
|
-
return vm.cmpProps[key];
|
|
2452
|
-
},
|
|
2453
|
-
set(newValue) {
|
|
2454
|
-
const vm = getAssociatedVM(this);
|
|
2455
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2456
|
-
const vmBeingRendered = getVMBeingRendered();
|
|
2457
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2458
|
-
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2459
|
-
}
|
|
2460
|
-
vm.cmpProps[key] = newValue;
|
|
2461
|
-
componentValueMutated(vm, key);
|
|
2462
|
-
},
|
|
2463
|
-
enumerable: true,
|
|
2464
|
-
configurable: true,
|
|
2465
|
-
};
|
|
2566
|
+
function createFieldDataCallback(vm, name) {
|
|
2567
|
+
return value => {
|
|
2568
|
+
updateComponentValue(vm, name, value);
|
|
2569
|
+
};
|
|
2466
2570
|
}
|
|
2467
|
-
function
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2571
|
+
function createMethodDataCallback(vm, method) {
|
|
2572
|
+
return value => {
|
|
2573
|
+
// dispatching new value into the wired method
|
|
2574
|
+
runWithBoundaryProtection(vm, vm.owner, noop, () => {
|
|
2575
|
+
// job
|
|
2576
|
+
method.call(vm.component, value);
|
|
2577
|
+
}, noop);
|
|
2578
|
+
};
|
|
2579
|
+
}
|
|
2580
|
+
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
2581
|
+
let hasPendingConfig = false;
|
|
2582
|
+
// creating the reactive observer for reactive params when needed
|
|
2583
|
+
const ro = createReactiveObserver(() => {
|
|
2584
|
+
if (hasPendingConfig === false) {
|
|
2585
|
+
hasPendingConfig = true;
|
|
2586
|
+
// collect new config in the micro-task
|
|
2587
|
+
Promise.resolve().then(() => {
|
|
2588
|
+
hasPendingConfig = false;
|
|
2589
|
+
// resetting current reactive params
|
|
2590
|
+
ro.reset();
|
|
2591
|
+
// dispatching a new config due to a change in the configuration
|
|
2592
|
+
computeConfigAndUpdate();
|
|
2593
|
+
});
|
|
2474
2594
|
}
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2489
|
-
}
|
|
2490
|
-
if (set) {
|
|
2491
|
-
set.call(this, newValue);
|
|
2492
|
-
}
|
|
2493
|
-
else if (process.env.NODE_ENV !== 'production') {
|
|
2494
|
-
assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
|
|
2495
|
-
}
|
|
2496
|
-
},
|
|
2497
|
-
enumerable,
|
|
2498
|
-
configurable,
|
|
2499
|
-
};
|
|
2595
|
+
});
|
|
2596
|
+
const computeConfigAndUpdate = () => {
|
|
2597
|
+
let config;
|
|
2598
|
+
ro.observe(() => config = configCallback(component));
|
|
2599
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
2600
|
+
// TODO: dev-mode validation of config based on the adapter.configSchema
|
|
2601
|
+
// @ts-ignore it is assigned in the observe() callback
|
|
2602
|
+
callbackWhenConfigIsReady(config);
|
|
2603
|
+
};
|
|
2604
|
+
return {
|
|
2605
|
+
computeConfigAndUpdate,
|
|
2606
|
+
ro
|
|
2607
|
+
};
|
|
2500
2608
|
}
|
|
2609
|
+
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
2610
|
+
const {
|
|
2611
|
+
adapter
|
|
2612
|
+
} = wireDef;
|
|
2613
|
+
const adapterContextToken = getAdapterToken(adapter);
|
|
2614
|
+
if (isUndefined$1(adapterContextToken)) {
|
|
2615
|
+
return; // no provider found, nothing to be done
|
|
2616
|
+
}
|
|
2501
2617
|
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
return getReactiveProxy(target);
|
|
2618
|
+
const {
|
|
2619
|
+
elm,
|
|
2620
|
+
context: {
|
|
2621
|
+
wiredConnecting,
|
|
2622
|
+
wiredDisconnecting
|
|
2623
|
+
},
|
|
2624
|
+
renderer: {
|
|
2625
|
+
dispatchEvent
|
|
2511
2626
|
}
|
|
2627
|
+
} = vm;
|
|
2628
|
+
// waiting for the component to be connected to formally request the context via the token
|
|
2629
|
+
ArrayPush$1.call(wiredConnecting, () => {
|
|
2630
|
+
// This event is responsible for connecting the host element with another
|
|
2631
|
+
// element in the composed path that is providing contextual data. The provider
|
|
2632
|
+
// must be listening for a special dom event with the name corresponding to the value of
|
|
2633
|
+
// `adapterContextToken`, which will remain secret and internal to this file only to
|
|
2634
|
+
// guarantee that the linkage can be forged.
|
|
2635
|
+
const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
|
|
2636
|
+
setNewContext(newContext) {
|
|
2637
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
2638
|
+
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
2639
|
+
callbackWhenContextIsReady(newContext);
|
|
2640
|
+
},
|
|
2641
|
+
setDisconnectedCallback(disconnectCallback) {
|
|
2642
|
+
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
2643
|
+
// the the element hosting the wire is disconnected
|
|
2644
|
+
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
2645
|
+
}
|
|
2646
|
+
});
|
|
2647
|
+
dispatchEvent(elm, contextRegistrationEvent);
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
function createConnector(vm, name, wireDef) {
|
|
2651
|
+
const {
|
|
2652
|
+
method,
|
|
2653
|
+
adapter,
|
|
2654
|
+
configCallback,
|
|
2655
|
+
dynamic
|
|
2656
|
+
} = wireDef;
|
|
2657
|
+
let debugInfo;
|
|
2658
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2659
|
+
const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
|
|
2660
|
+
debugInfo = create(null);
|
|
2661
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
2662
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
|
|
2663
|
+
}
|
|
2664
|
+
const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
2665
|
+
const dataCallback = value => {
|
|
2512
2666
|
if (process.env.NODE_ENV !== 'production') {
|
|
2513
|
-
|
|
2667
|
+
debugInfo.data = value;
|
|
2668
|
+
// Note: most of the time, the data provided is for the current config, but there may be
|
|
2669
|
+
// some conditions in which it does not, ex:
|
|
2670
|
+
// race conditions in a poor network while the adapter does not cancel a previous request.
|
|
2671
|
+
debugInfo.wasDataProvisionedForConfig = true;
|
|
2514
2672
|
}
|
|
2515
|
-
|
|
2516
|
-
}
|
|
2673
|
+
fieldOrMethodCallback(value);
|
|
2674
|
+
};
|
|
2675
|
+
let context;
|
|
2676
|
+
let connector;
|
|
2677
|
+
// Workaround to pass the component element associated to this wire adapter instance.
|
|
2678
|
+
defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
2679
|
+
value: vm.elm
|
|
2680
|
+
});
|
|
2681
|
+
defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
|
|
2682
|
+
value: dynamic
|
|
2683
|
+
});
|
|
2684
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2685
|
+
// job
|
|
2686
|
+
connector = new adapter(dataCallback);
|
|
2687
|
+
}, noop);
|
|
2688
|
+
const updateConnectorConfig = config => {
|
|
2689
|
+
// every time the config is recomputed due to tracking,
|
|
2690
|
+
// this callback will be invoked with the new computed config
|
|
2691
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2692
|
+
// job
|
|
2693
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2694
|
+
debugInfo.config = config;
|
|
2695
|
+
debugInfo.context = context;
|
|
2696
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
2697
|
+
}
|
|
2698
|
+
connector.update(config, context);
|
|
2699
|
+
}, noop);
|
|
2700
|
+
};
|
|
2701
|
+
// Computes the current wire config and calls the update method on the wire adapter.
|
|
2702
|
+
// If it has params, we will need to observe changes in the next tick.
|
|
2703
|
+
const {
|
|
2704
|
+
computeConfigAndUpdate,
|
|
2705
|
+
ro
|
|
2706
|
+
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
2707
|
+
// if the adapter needs contextualization, we need to watch for new context and push it alongside the config
|
|
2708
|
+
if (!isUndefined$1(adapter.contextSchema)) {
|
|
2709
|
+
createContextWatcher(vm, wireDef, newContext => {
|
|
2710
|
+
// every time the context is pushed into this component,
|
|
2711
|
+
// this callback will be invoked with the new computed context
|
|
2712
|
+
if (context !== newContext) {
|
|
2713
|
+
context = newContext;
|
|
2714
|
+
// Note: when new context arrives, the config will be recomputed and pushed along side the new
|
|
2715
|
+
// context, this is to preserve the identity characteristics, config should not have identity
|
|
2716
|
+
// (ever), while context can have identity
|
|
2717
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
2718
|
+
computeConfigAndUpdate();
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
});
|
|
2722
|
+
}
|
|
2723
|
+
return {
|
|
2724
|
+
// @ts-ignore the boundary protection executes sync, connector is always defined
|
|
2725
|
+
connector,
|
|
2726
|
+
computeConfigAndUpdate,
|
|
2727
|
+
resetConfigWatcher: () => ro.reset()
|
|
2728
|
+
};
|
|
2729
|
+
}
|
|
2730
|
+
const AdapterToTokenMap = new Map();
|
|
2731
|
+
function getAdapterToken(adapter) {
|
|
2732
|
+
return AdapterToTokenMap.get(adapter);
|
|
2733
|
+
}
|
|
2734
|
+
function setAdapterToken(adapter, token) {
|
|
2735
|
+
AdapterToTokenMap.set(adapter, token);
|
|
2736
|
+
}
|
|
2737
|
+
function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2738
|
+
// support for callable adapters
|
|
2739
|
+
if (adapter.adapter) {
|
|
2740
|
+
adapter = adapter.adapter;
|
|
2741
|
+
}
|
|
2742
|
+
const method = descriptor.value;
|
|
2743
|
+
const def = {
|
|
2744
|
+
adapter,
|
|
2745
|
+
method,
|
|
2746
|
+
configCallback,
|
|
2747
|
+
dynamic
|
|
2748
|
+
};
|
|
2749
|
+
WireMetaMap.set(descriptor, def);
|
|
2750
|
+
}
|
|
2751
|
+
function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
|
|
2752
|
+
// support for callable adapters
|
|
2753
|
+
if (adapter.adapter) {
|
|
2754
|
+
adapter = adapter.adapter;
|
|
2755
|
+
}
|
|
2756
|
+
const def = {
|
|
2757
|
+
adapter,
|
|
2758
|
+
configCallback,
|
|
2759
|
+
dynamic
|
|
2760
|
+
};
|
|
2761
|
+
WireMetaMap.set(descriptor, def);
|
|
2762
|
+
}
|
|
2763
|
+
function installWireAdapters(vm) {
|
|
2764
|
+
const {
|
|
2765
|
+
context,
|
|
2766
|
+
def: {
|
|
2767
|
+
wire
|
|
2768
|
+
}
|
|
2769
|
+
} = vm;
|
|
2770
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2771
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
|
|
2772
|
+
}
|
|
2773
|
+
const wiredConnecting = context.wiredConnecting = [];
|
|
2774
|
+
const wiredDisconnecting = context.wiredDisconnecting = [];
|
|
2775
|
+
for (const fieldNameOrMethod in wire) {
|
|
2776
|
+
const descriptor = wire[fieldNameOrMethod];
|
|
2777
|
+
const wireDef = WireMetaMap.get(descriptor);
|
|
2778
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2779
|
+
assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
|
|
2780
|
+
}
|
|
2781
|
+
if (!isUndefined$1(wireDef)) {
|
|
2782
|
+
const {
|
|
2783
|
+
connector,
|
|
2784
|
+
computeConfigAndUpdate,
|
|
2785
|
+
resetConfigWatcher
|
|
2786
|
+
} = createConnector(vm, fieldNameOrMethod, wireDef);
|
|
2787
|
+
const hasDynamicParams = wireDef.dynamic.length > 0;
|
|
2788
|
+
ArrayPush$1.call(wiredConnecting, () => {
|
|
2789
|
+
connector.connect();
|
|
2790
|
+
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
2791
|
+
if (hasDynamicParams) {
|
|
2792
|
+
Promise.resolve().then(computeConfigAndUpdate);
|
|
2793
|
+
return;
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
computeConfigAndUpdate();
|
|
2797
|
+
});
|
|
2798
|
+
ArrayPush$1.call(wiredDisconnecting, () => {
|
|
2799
|
+
connector.disconnect();
|
|
2800
|
+
resetConfigWatcher();
|
|
2801
|
+
});
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
function connectWireAdapters(vm) {
|
|
2806
|
+
const {
|
|
2807
|
+
wiredConnecting
|
|
2808
|
+
} = vm.context;
|
|
2809
|
+
for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
|
2810
|
+
wiredConnecting[i]();
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
function disconnectWireAdapters(vm) {
|
|
2814
|
+
const {
|
|
2815
|
+
wiredDisconnecting
|
|
2816
|
+
} = vm.context;
|
|
2817
|
+
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
2818
|
+
// job
|
|
2819
|
+
for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
|
|
2820
|
+
wiredDisconnecting[i]();
|
|
2821
|
+
}
|
|
2822
|
+
}, noop);
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
/*
|
|
2826
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2827
|
+
* All rights reserved.
|
|
2828
|
+
* SPDX-License-Identifier: MIT
|
|
2829
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2830
|
+
*/
|
|
2831
|
+
function api$1() {
|
|
2832
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2833
|
+
assert.fail(`@api decorator can only be used as a decorator function.`);
|
|
2834
|
+
}
|
|
2835
|
+
throw new Error();
|
|
2836
|
+
}
|
|
2837
|
+
function createPublicPropertyDescriptor(key) {
|
|
2838
|
+
return {
|
|
2839
|
+
get() {
|
|
2840
|
+
const vm = getAssociatedVM(this);
|
|
2841
|
+
if (isBeingConstructed(vm)) {
|
|
2842
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2843
|
+
logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
2844
|
+
}
|
|
2845
|
+
return;
|
|
2846
|
+
}
|
|
2847
|
+
componentValueObserved(vm, key);
|
|
2848
|
+
return vm.cmpProps[key];
|
|
2849
|
+
},
|
|
2850
|
+
set(newValue) {
|
|
2851
|
+
const vm = getAssociatedVM(this);
|
|
2852
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2853
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2854
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2855
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2856
|
+
}
|
|
2857
|
+
vm.cmpProps[key] = newValue;
|
|
2858
|
+
componentValueMutated(vm, key);
|
|
2859
|
+
},
|
|
2860
|
+
enumerable: true,
|
|
2861
|
+
configurable: true,
|
|
2862
|
+
};
|
|
2863
|
+
}
|
|
2864
|
+
function createPublicAccessorDescriptor(key, descriptor) {
|
|
2865
|
+
const { get, set, enumerable, configurable } = descriptor;
|
|
2866
|
+
if (!isFunction$1(get)) {
|
|
2867
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2868
|
+
assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
|
|
2869
|
+
}
|
|
2870
|
+
throw new Error();
|
|
2871
|
+
}
|
|
2872
|
+
return {
|
|
2873
|
+
get() {
|
|
2874
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2875
|
+
// Assert that the this value is an actual Component with an associated VM.
|
|
2876
|
+
getAssociatedVM(this);
|
|
2877
|
+
}
|
|
2878
|
+
return get.call(this);
|
|
2879
|
+
},
|
|
2880
|
+
set(newValue) {
|
|
2881
|
+
const vm = getAssociatedVM(this);
|
|
2882
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2883
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2884
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2885
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2886
|
+
}
|
|
2887
|
+
if (set) {
|
|
2888
|
+
set.call(this, newValue);
|
|
2889
|
+
}
|
|
2890
|
+
else if (process.env.NODE_ENV !== 'production') {
|
|
2891
|
+
assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
|
|
2892
|
+
}
|
|
2893
|
+
},
|
|
2894
|
+
enumerable,
|
|
2895
|
+
configurable,
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2899
|
+
/*
|
|
2900
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2901
|
+
* All rights reserved.
|
|
2902
|
+
* SPDX-License-Identifier: MIT
|
|
2903
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2904
|
+
*/
|
|
2905
|
+
function track(target) {
|
|
2906
|
+
if (arguments.length === 1) {
|
|
2907
|
+
return getReactiveProxy(target);
|
|
2908
|
+
}
|
|
2909
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2910
|
+
assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
|
|
2911
|
+
}
|
|
2912
|
+
throw new Error();
|
|
2913
|
+
}
|
|
2517
2914
|
function internalTrackDecorator(key) {
|
|
2518
2915
|
return {
|
|
2519
2916
|
get() {
|
|
@@ -3476,6 +3873,9 @@ function updateStylesheetToken(vm, template) {
|
|
|
3476
3873
|
stylesheets: newStylesheets,
|
|
3477
3874
|
stylesheetToken: newStylesheetToken
|
|
3478
3875
|
} = template;
|
|
3876
|
+
const {
|
|
3877
|
+
stylesheets: newVmStylesheets
|
|
3878
|
+
} = vm;
|
|
3479
3879
|
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
3480
3880
|
const {
|
|
3481
3881
|
hasScopedStyles
|
|
@@ -3499,7 +3899,9 @@ function updateStylesheetToken(vm, template) {
|
|
|
3499
3899
|
}
|
|
3500
3900
|
// Apply the new template styling token to the host element, if the new template has any
|
|
3501
3901
|
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3502
|
-
|
|
3902
|
+
const hasNewStylesheets = hasStyles(newStylesheets);
|
|
3903
|
+
const hasNewVmStylesheets = hasStyles(newVmStylesheets);
|
|
3904
|
+
if (hasNewStylesheets || hasNewVmStylesheets) {
|
|
3503
3905
|
newToken = newStylesheetToken;
|
|
3504
3906
|
}
|
|
3505
3907
|
// Set the new styling token on the host element
|
|
@@ -3571,10 +3973,17 @@ function getStylesheetsContent(vm, template) {
|
|
|
3571
3973
|
stylesheets,
|
|
3572
3974
|
stylesheetToken
|
|
3573
3975
|
} = template;
|
|
3976
|
+
const {
|
|
3977
|
+
stylesheets: vmStylesheets
|
|
3978
|
+
} = vm;
|
|
3574
3979
|
let content = [];
|
|
3575
|
-
if (
|
|
3980
|
+
if (hasStyles(stylesheets)) {
|
|
3576
3981
|
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
3577
3982
|
}
|
|
3983
|
+
// VM (component) stylesheets apply after template stylesheets
|
|
3984
|
+
if (hasStyles(vmStylesheets)) {
|
|
3985
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
|
|
3986
|
+
}
|
|
3578
3987
|
return content;
|
|
3579
3988
|
}
|
|
3580
3989
|
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
@@ -3612,10 +4021,13 @@ function getStylesheetTokenHost(vnode) {
|
|
|
3612
4021
|
const {
|
|
3613
4022
|
template
|
|
3614
4023
|
} = getComponentInternalDef(vnode.ctor);
|
|
4024
|
+
const {
|
|
4025
|
+
vm
|
|
4026
|
+
} = vnode;
|
|
3615
4027
|
const {
|
|
3616
4028
|
stylesheetToken
|
|
3617
4029
|
} = template;
|
|
3618
|
-
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
4030
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
|
|
3619
4031
|
}
|
|
3620
4032
|
function getNearestNativeShadowComponent(vm) {
|
|
3621
4033
|
const owner = getNearestShadowComponent(vm);
|
|
@@ -4228,6 +4640,28 @@ function patchCustomElement(n1, n2, parent, renderer) {
|
|
|
4228
4640
|
// in fallback mode, the allocation will always set children to
|
|
4229
4641
|
// empty and delegate the real allocation to the slot elements
|
|
4230
4642
|
allocateChildren(n2, vm);
|
|
4643
|
+
// Solves an edge case with slotted VFragments in native shadow mode.
|
|
4644
|
+
//
|
|
4645
|
+
// During allocation, in native shadow, slotted VFragment nodes are flattened and their text delimiters are removed
|
|
4646
|
+
// to avoid interfering with native slot behavior. When this happens, if any of the fragments
|
|
4647
|
+
// were not stable, the children must go through the dynamic diffing algo.
|
|
4648
|
+
//
|
|
4649
|
+
// If the new children (n2.children) contain no VFragments, but the previous children (n1.children) were dynamic,
|
|
4650
|
+
// the new nodes must be marked dynamic so that all nodes are properly updated. The only indicator that the new
|
|
4651
|
+
// nodes need to be dynamic comes from the previous children, so we check that to determine whether we need to
|
|
4652
|
+
// mark the new children dynamic.
|
|
4653
|
+
//
|
|
4654
|
+
// Example:
|
|
4655
|
+
// n1.children: [div, VFragment('', div, null, ''), div] => [div, div, null, div]; // marked dynamic
|
|
4656
|
+
// n2.children: [div, null, div] => [div, null, div] // marked ???
|
|
4657
|
+
const {
|
|
4658
|
+
shadowMode,
|
|
4659
|
+
renderMode
|
|
4660
|
+
} = vm;
|
|
4661
|
+
if (shadowMode == 0 /* ShadowMode.Native */ && renderMode !== 0 /* RenderMode.Light */ && hasDynamicChildren(n1.children)) {
|
|
4662
|
+
// No-op if children has already been marked dynamic by 'allocateChildren()'.
|
|
4663
|
+
markAsDynamicChildren(n2.children);
|
|
4664
|
+
}
|
|
4231
4665
|
}
|
|
4232
4666
|
// in fallback mode, the children will be always empty, so, nothing
|
|
4233
4667
|
// will happen, but in native, it does allocate the light dom
|
|
@@ -4420,7 +4854,6 @@ function allocateChildren(vnode, vm) {
|
|
|
4420
4854
|
//
|
|
4421
4855
|
// In case #2, we will always get a fresh VCustomElement.
|
|
4422
4856
|
const children = vnode.aChildren || vnode.children;
|
|
4423
|
-
vm.aChildren = children;
|
|
4424
4857
|
const {
|
|
4425
4858
|
renderMode,
|
|
4426
4859
|
shadowMode
|
|
@@ -4433,20 +4866,66 @@ function allocateChildren(vnode, vm) {
|
|
|
4433
4866
|
logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
|
|
4434
4867
|
}
|
|
4435
4868
|
}
|
|
4869
|
+
// If any of the children being allocated are VFragments, we remove the text delimiters and flatten all immediate
|
|
4870
|
+
// children VFragments to avoid them interfering with default slot behavior.
|
|
4871
|
+
const allocatedChildren = flattenFragmentsInChildren(children);
|
|
4872
|
+
vnode.children = allocatedChildren;
|
|
4873
|
+
vm.aChildren = allocatedChildren;
|
|
4436
4874
|
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4437
4875
|
// slow path
|
|
4438
|
-
allocateInSlot(vm,
|
|
4876
|
+
allocateInSlot(vm, allocatedChildren, vnode.owner);
|
|
4439
4877
|
// save the allocated children in case this vnode is reused.
|
|
4440
|
-
vnode.aChildren =
|
|
4878
|
+
vnode.aChildren = allocatedChildren;
|
|
4441
4879
|
// every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4442
4880
|
vnode.children = EmptyArray;
|
|
4443
4881
|
}
|
|
4444
4882
|
}
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4883
|
+
/**
|
|
4884
|
+
* Flattens the contents of all VFragments in an array of VNodes, removes the text delimiters on those VFragments, and
|
|
4885
|
+
* marks the resulting children array as dynamic. Uses a stack (array) to iteratively traverse the nested VFragments
|
|
4886
|
+
* and avoid the perf overhead of creating/destroying throwaway arrays/objects in a recursive approach.
|
|
4887
|
+
*
|
|
4888
|
+
* With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
|
|
4889
|
+
*
|
|
4890
|
+
* This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
|
|
4891
|
+
*/
|
|
4892
|
+
function flattenFragmentsInChildren(children) {
|
|
4893
|
+
const flattenedChildren = [];
|
|
4894
|
+
// Initialize our stack with the direct children of the custom component and check whether we have a VFragment.
|
|
4895
|
+
// If no VFragment is found in children, we don't need to traverse anything or mark the children dynamic and can return early.
|
|
4896
|
+
const nodeStack = [];
|
|
4897
|
+
let fragmentFound = false;
|
|
4898
|
+
for (let i = children.length - 1; i > -1; i -= 1) {
|
|
4899
|
+
const child = children[i];
|
|
4900
|
+
ArrayPush$1.call(nodeStack, child);
|
|
4901
|
+
fragmentFound = fragmentFound || !!(child && isVFragment(child));
|
|
4902
|
+
}
|
|
4903
|
+
if (!fragmentFound) {
|
|
4904
|
+
return children;
|
|
4905
|
+
}
|
|
4906
|
+
let currentNode;
|
|
4907
|
+
while (!isUndefined$1(currentNode = ArrayPop.call(nodeStack))) {
|
|
4908
|
+
if (!isNull(currentNode) && isVFragment(currentNode)) {
|
|
4909
|
+
const fChildren = currentNode.children;
|
|
4910
|
+
// Ignore the start and end text node delimiters
|
|
4911
|
+
for (let i = fChildren.length - 2; i > 0; i -= 1) {
|
|
4912
|
+
ArrayPush$1.call(nodeStack, fChildren[i]);
|
|
4913
|
+
}
|
|
4914
|
+
} else {
|
|
4915
|
+
ArrayPush$1.call(flattenedChildren, currentNode);
|
|
4916
|
+
}
|
|
4917
|
+
}
|
|
4918
|
+
// We always mark the children as dynamic because nothing generates stable VFragments yet.
|
|
4919
|
+
// If/when stable VFragments are generated by the compiler, this code should be updated to
|
|
4920
|
+
// not mark dynamic if all flattened VFragments were stable.
|
|
4921
|
+
markAsDynamicChildren(flattenedChildren);
|
|
4922
|
+
return flattenedChildren;
|
|
4923
|
+
}
|
|
4924
|
+
function createViewModelHook(elm, vnode, renderer) {
|
|
4925
|
+
let vm = getAssociatedVMIfPresent(elm);
|
|
4926
|
+
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
4927
|
+
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
4928
|
+
// called right after invoking `document.createElement`.
|
|
4450
4929
|
if (!isUndefined$1(vm)) {
|
|
4451
4930
|
return vm;
|
|
4452
4931
|
}
|
|
@@ -4466,22 +4945,20 @@ function createViewModelHook(elm, vnode, renderer) {
|
|
|
4466
4945
|
}
|
|
4467
4946
|
return vm;
|
|
4468
4947
|
}
|
|
4469
|
-
|
|
4470
|
-
* Collects all slots into a SlotSet, traversing through VFragment Nodes
|
|
4471
|
-
*/
|
|
4472
|
-
function collectSlots(vm, children, cmpSlotsMapping) {
|
|
4948
|
+
function allocateInSlot(vm, children, owner) {
|
|
4473
4949
|
var _a, _b;
|
|
4950
|
+
const {
|
|
4951
|
+
cmpSlots: {
|
|
4952
|
+
slotAssignments: oldSlotsMapping
|
|
4953
|
+
}
|
|
4954
|
+
} = vm;
|
|
4955
|
+
const cmpSlotsMapping = create(null);
|
|
4956
|
+
// Collect all slots into cmpSlotsMapping
|
|
4474
4957
|
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4475
4958
|
const vnode = children[i];
|
|
4476
4959
|
if (isNull(vnode)) {
|
|
4477
4960
|
continue;
|
|
4478
4961
|
}
|
|
4479
|
-
// Dive further iff the content is wrapped in a VFragment
|
|
4480
|
-
if (isVFragment(vnode)) {
|
|
4481
|
-
// Remove the text delimiter nodes to avoid overriding default slot content
|
|
4482
|
-
collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
|
|
4483
|
-
continue;
|
|
4484
|
-
}
|
|
4485
4962
|
let slotName = '';
|
|
4486
4963
|
if (isVBaseElement(vnode)) {
|
|
4487
4964
|
slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
|
|
@@ -4491,15 +4968,6 @@ function collectSlots(vm, children, cmpSlotsMapping) {
|
|
|
4491
4968
|
const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
|
|
4492
4969
|
ArrayPush$1.call(vnodes, vnode);
|
|
4493
4970
|
}
|
|
4494
|
-
}
|
|
4495
|
-
function allocateInSlot(vm, children, owner) {
|
|
4496
|
-
const {
|
|
4497
|
-
cmpSlots: {
|
|
4498
|
-
slotAssignments: oldSlotsMapping
|
|
4499
|
-
}
|
|
4500
|
-
} = vm;
|
|
4501
|
-
const cmpSlotsMapping = create(null);
|
|
4502
|
-
collectSlots(vm, children, cmpSlotsMapping);
|
|
4503
4971
|
vm.cmpSlots = {
|
|
4504
4972
|
owner,
|
|
4505
4973
|
slotAssignments: cmpSlotsMapping
|
|
@@ -4530,14 +4998,14 @@ function allocateInSlot(vm, children, owner) {
|
|
|
4530
4998
|
}
|
|
4531
4999
|
}
|
|
4532
5000
|
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4533
|
-
const
|
|
4534
|
-
// dynamic children means it was generated by an iteration
|
|
4535
|
-
//
|
|
5001
|
+
const DynamicChildren = new WeakMap();
|
|
5002
|
+
// dynamic children means it was either generated by an iteration in a template
|
|
5003
|
+
// or part of an unstable fragment, and will require a more complex diffing algo.
|
|
4536
5004
|
function markAsDynamicChildren(children) {
|
|
4537
|
-
|
|
5005
|
+
DynamicChildren.set(children, 1);
|
|
4538
5006
|
}
|
|
4539
5007
|
function hasDynamicChildren(children) {
|
|
4540
|
-
return
|
|
5008
|
+
return DynamicChildren.has(children);
|
|
4541
5009
|
}
|
|
4542
5010
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
4543
5011
|
const map = {};
|
|
@@ -5403,7 +5871,7 @@ function evaluateTemplate(vm, html) {
|
|
|
5403
5871
|
// Create a brand new template cache for the swapped templated.
|
|
5404
5872
|
context.tplCache = create(null);
|
|
5405
5873
|
// Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
|
|
5406
|
-
context.hasScopedStyles = computeHasScopedStyles(html);
|
|
5874
|
+
context.hasScopedStyles = computeHasScopedStyles(html, vm);
|
|
5407
5875
|
// Update the scoping token on the host element.
|
|
5408
5876
|
updateStylesheetToken(vm, html);
|
|
5409
5877
|
// Evaluate, create stylesheet and cache the produced VNode for future
|
|
@@ -5446,9 +5914,8 @@ function evaluateTemplate(vm, html) {
|
|
|
5446
5914
|
}
|
|
5447
5915
|
return vnodes;
|
|
5448
5916
|
}
|
|
5449
|
-
function
|
|
5450
|
-
|
|
5451
|
-
if (!isUndefined$1(stylesheets)) {
|
|
5917
|
+
function computeHasScopedStylesInStylesheets(stylesheets) {
|
|
5918
|
+
if (hasStyles(stylesheets)) {
|
|
5452
5919
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
5453
5920
|
if (isTrue(stylesheets[i][KEY__SCOPED_CSS])) {
|
|
5454
5921
|
return true;
|
|
@@ -5457,6 +5924,15 @@ function computeHasScopedStyles(template) {
|
|
|
5457
5924
|
}
|
|
5458
5925
|
return false;
|
|
5459
5926
|
}
|
|
5927
|
+
function computeHasScopedStyles(template, vm) {
|
|
5928
|
+
const { stylesheets } = template;
|
|
5929
|
+
const vmStylesheets = !isUndefined$1(vm) ? vm.stylesheets : null;
|
|
5930
|
+
return (computeHasScopedStylesInStylesheets(stylesheets) ||
|
|
5931
|
+
computeHasScopedStylesInStylesheets(vmStylesheets));
|
|
5932
|
+
}
|
|
5933
|
+
function hasStyles(stylesheets) {
|
|
5934
|
+
return !isUndefined$1(stylesheets) && !isNull(stylesheets) && stylesheets.length > 0;
|
|
5935
|
+
}
|
|
5460
5936
|
|
|
5461
5937
|
/*
|
|
5462
5938
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5772,6 +6248,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5772
6248
|
// Properties set right after VM creation.
|
|
5773
6249
|
tro: null,
|
|
5774
6250
|
shadowMode: null,
|
|
6251
|
+
stylesheets: null,
|
|
5775
6252
|
// Properties set by the LightningElement constructor.
|
|
5776
6253
|
component: null,
|
|
5777
6254
|
shadowRoot: null,
|
|
@@ -5784,6 +6261,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5784
6261
|
if (process.env.NODE_ENV !== 'production') {
|
|
5785
6262
|
vm.debugInfo = create(null);
|
|
5786
6263
|
}
|
|
6264
|
+
vm.stylesheets = computeStylesheets(vm, def.ctor);
|
|
5787
6265
|
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5788
6266
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
5789
6267
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5802,6 +6280,42 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5802
6280
|
}
|
|
5803
6281
|
return vm;
|
|
5804
6282
|
}
|
|
6283
|
+
function validateComponentStylesheets(vm, stylesheets) {
|
|
6284
|
+
let valid = true;
|
|
6285
|
+
const validate = arrayOrStylesheet => {
|
|
6286
|
+
if (isArray$1(arrayOrStylesheet)) {
|
|
6287
|
+
for (let i = 0; i < arrayOrStylesheet.length; i++) {
|
|
6288
|
+
validate(arrayOrStylesheet[i]);
|
|
6289
|
+
}
|
|
6290
|
+
} else if (!isFunction$1(arrayOrStylesheet)) {
|
|
6291
|
+
// function assumed to be a stylesheet factory
|
|
6292
|
+
valid = false;
|
|
6293
|
+
}
|
|
6294
|
+
};
|
|
6295
|
+
if (!isArray$1(stylesheets)) {
|
|
6296
|
+
valid = false;
|
|
6297
|
+
} else {
|
|
6298
|
+
validate(stylesheets);
|
|
6299
|
+
}
|
|
6300
|
+
return valid;
|
|
6301
|
+
}
|
|
6302
|
+
// Validate and flatten any stylesheets defined as `static stylesheets`
|
|
6303
|
+
function computeStylesheets(vm, ctor) {
|
|
6304
|
+
if (lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
|
|
6305
|
+
const {
|
|
6306
|
+
stylesheets
|
|
6307
|
+
} = ctor;
|
|
6308
|
+
if (!isUndefined$1(stylesheets)) {
|
|
6309
|
+
const valid = validateComponentStylesheets(vm, stylesheets);
|
|
6310
|
+
if (valid) {
|
|
6311
|
+
return flattenStylesheets(stylesheets);
|
|
6312
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
6313
|
+
logError(`static stylesheets must be an array of CSS stylesheets. Found invalid stylesheets on <${vm.tagName}>`, vm);
|
|
6314
|
+
}
|
|
6315
|
+
}
|
|
6316
|
+
}
|
|
6317
|
+
return null;
|
|
6318
|
+
}
|
|
5805
6319
|
function computeShadowMode(vm, renderer) {
|
|
5806
6320
|
const {
|
|
5807
6321
|
def
|
|
@@ -6044,411 +6558,268 @@ function runChildNodesDisconnectedCallback(vm) {
|
|
|
6044
6558
|
// in the case where the VM failed in the middle of its creation,
|
|
6045
6559
|
// eg: constructor throwing before invoking super().
|
|
6046
6560
|
if (!isUndefined$1(childVM)) {
|
|
6047
|
-
resetComponentStateWhenRemoved(childVM);
|
|
6048
|
-
}
|
|
6049
|
-
}
|
|
6050
|
-
}
|
|
6051
|
-
}
|
|
6052
|
-
function runLightChildNodesDisconnectedCallback(vm) {
|
|
6053
|
-
const {
|
|
6054
|
-
aChildren: adoptedChildren
|
|
6055
|
-
} = vm;
|
|
6056
|
-
recursivelyDisconnectChildren(adoptedChildren);
|
|
6057
|
-
}
|
|
6058
|
-
/**
|
|
6059
|
-
* The recursion doesn't need to be a complete traversal of the vnode graph,
|
|
6060
|
-
* instead it can be partial, when a custom element vnode is found, we don't
|
|
6061
|
-
* need to continue into its children because by attempting to disconnect the
|
|
6062
|
-
* custom element itself will trigger the removal of anything slotted or anything
|
|
6063
|
-
* defined on its shadow.
|
|
6064
|
-
*/
|
|
6065
|
-
function recursivelyDisconnectChildren(vnodes) {
|
|
6066
|
-
for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
|
6067
|
-
const vnode = vnodes[i];
|
|
6068
|
-
if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
|
|
6069
|
-
switch (vnode.type) {
|
|
6070
|
-
case 2 /* VNodeType.Element */:
|
|
6071
|
-
recursivelyDisconnectChildren(vnode.children);
|
|
6072
|
-
break;
|
|
6073
|
-
case 3 /* VNodeType.CustomElement */:
|
|
6074
|
-
{
|
|
6075
|
-
const vm = getAssociatedVM(vnode.elm);
|
|
6076
|
-
resetComponentStateWhenRemoved(vm);
|
|
6077
|
-
break;
|
|
6078
|
-
}
|
|
6079
|
-
}
|
|
6080
|
-
}
|
|
6081
|
-
}
|
|
6082
|
-
}
|
|
6083
|
-
// This is a super optimized mechanism to remove the content of the root node (shadow root
|
|
6084
|
-
// for shadow DOM components and the root element itself for light DOM) without having to go
|
|
6085
|
-
// into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
|
|
6086
|
-
// children VNodes might not be representing the current state of the DOM.
|
|
6087
|
-
function resetComponentRoot(vm) {
|
|
6088
|
-
const {
|
|
6089
|
-
children,
|
|
6090
|
-
renderRoot,
|
|
6091
|
-
renderer: {
|
|
6092
|
-
remove
|
|
6093
|
-
}
|
|
6094
|
-
} = vm;
|
|
6095
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
6096
|
-
const child = children[i];
|
|
6097
|
-
if (!isNull(child) && !isUndefined$1(child.elm)) {
|
|
6098
|
-
remove(child.elm, renderRoot);
|
|
6099
|
-
}
|
|
6100
|
-
}
|
|
6101
|
-
vm.children = EmptyArray;
|
|
6102
|
-
runChildNodesDisconnectedCallback(vm);
|
|
6103
|
-
vm.velements = EmptyArray;
|
|
6104
|
-
}
|
|
6105
|
-
function scheduleRehydration(vm) {
|
|
6106
|
-
if (isTrue(vm.isScheduled)) {
|
|
6107
|
-
return;
|
|
6108
|
-
}
|
|
6109
|
-
vm.isScheduled = true;
|
|
6110
|
-
if (rehydrateQueue.length === 0) {
|
|
6111
|
-
addCallbackToNextTick(flushRehydrationQueue);
|
|
6112
|
-
}
|
|
6113
|
-
ArrayPush$1.call(rehydrateQueue, vm);
|
|
6114
|
-
}
|
|
6115
|
-
function getErrorBoundaryVM(vm) {
|
|
6116
|
-
let currentVm = vm;
|
|
6117
|
-
while (!isNull(currentVm)) {
|
|
6118
|
-
if (!isUndefined$1(currentVm.def.errorCallback)) {
|
|
6119
|
-
return currentVm;
|
|
6120
|
-
}
|
|
6121
|
-
currentVm = currentVm.owner;
|
|
6122
|
-
}
|
|
6123
|
-
}
|
|
6124
|
-
function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
|
6125
|
-
let error;
|
|
6126
|
-
pre();
|
|
6127
|
-
try {
|
|
6128
|
-
job();
|
|
6129
|
-
} catch (e) {
|
|
6130
|
-
error = Object(e);
|
|
6131
|
-
} finally {
|
|
6132
|
-
post();
|
|
6133
|
-
if (!isUndefined$1(error)) {
|
|
6134
|
-
addErrorComponentStack(vm, error);
|
|
6135
|
-
const errorBoundaryVm = isNull(owner) ? undefined : getErrorBoundaryVM(owner);
|
|
6136
|
-
if (isUndefined$1(errorBoundaryVm)) {
|
|
6137
|
-
throw error; // eslint-disable-line no-unsafe-finally
|
|
6138
|
-
}
|
|
6139
|
-
|
|
6140
|
-
resetComponentRoot(vm); // remove offenders
|
|
6141
|
-
logOperationStart(6 /* OperationId.ErrorCallback */, vm);
|
|
6142
|
-
// error boundaries must have an ErrorCallback
|
|
6143
|
-
const errorCallback = errorBoundaryVm.def.errorCallback;
|
|
6144
|
-
invokeComponentCallback(errorBoundaryVm, errorCallback, [error, error.wcStack]);
|
|
6145
|
-
logOperationEnd(6 /* OperationId.ErrorCallback */, vm);
|
|
6146
|
-
}
|
|
6147
|
-
}
|
|
6148
|
-
}
|
|
6149
|
-
function forceRehydration(vm) {
|
|
6150
|
-
// if we must reset the shadowRoot content and render the template
|
|
6151
|
-
// from scratch on an active instance, the way to force the reset
|
|
6152
|
-
// is by replacing the value of old template, which is used during
|
|
6153
|
-
// to determine if the template has changed or not during the rendering
|
|
6154
|
-
// process. If the template returned by render() is different from the
|
|
6155
|
-
// previous stored template, the styles will be reset, along with the
|
|
6156
|
-
// content of the shadowRoot, this way we can guarantee that all children
|
|
6157
|
-
// elements will be throw away, and new instances will be created.
|
|
6158
|
-
vm.cmpTemplate = () => [];
|
|
6159
|
-
if (isFalse(vm.isDirty)) {
|
|
6160
|
-
// forcing the vm to rehydrate in the next tick
|
|
6161
|
-
markComponentAsDirty(vm);
|
|
6162
|
-
scheduleRehydration(vm);
|
|
6163
|
-
}
|
|
6164
|
-
}
|
|
6165
|
-
|
|
6166
|
-
/*
|
|
6167
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
6168
|
-
* All rights reserved.
|
|
6169
|
-
* SPDX-License-Identifier: MIT
|
|
6170
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6171
|
-
*/
|
|
6172
|
-
const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
|
|
6173
|
-
const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
|
6174
|
-
const WIRE_DEBUG_ENTRY = '@wire';
|
|
6175
|
-
const WireMetaMap = new Map();
|
|
6176
|
-
class WireContextRegistrationEvent extends CustomEvent {
|
|
6177
|
-
constructor(adapterToken, {
|
|
6178
|
-
setNewContext,
|
|
6179
|
-
setDisconnectedCallback
|
|
6180
|
-
}) {
|
|
6181
|
-
super(adapterToken, {
|
|
6182
|
-
bubbles: true,
|
|
6183
|
-
composed: true
|
|
6184
|
-
});
|
|
6185
|
-
defineProperties(this, {
|
|
6186
|
-
setNewContext: {
|
|
6187
|
-
value: setNewContext
|
|
6188
|
-
},
|
|
6189
|
-
setDisconnectedCallback: {
|
|
6190
|
-
value: setDisconnectedCallback
|
|
6191
|
-
}
|
|
6192
|
-
});
|
|
6193
|
-
}
|
|
6194
|
-
}
|
|
6195
|
-
function createFieldDataCallback(vm, name) {
|
|
6196
|
-
return value => {
|
|
6197
|
-
updateComponentValue(vm, name, value);
|
|
6198
|
-
};
|
|
6199
|
-
}
|
|
6200
|
-
function createMethodDataCallback(vm, method) {
|
|
6201
|
-
return value => {
|
|
6202
|
-
// dispatching new value into the wired method
|
|
6203
|
-
runWithBoundaryProtection(vm, vm.owner, noop, () => {
|
|
6204
|
-
// job
|
|
6205
|
-
method.call(vm.component, value);
|
|
6206
|
-
}, noop);
|
|
6207
|
-
};
|
|
6208
|
-
}
|
|
6209
|
-
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
6210
|
-
let hasPendingConfig = false;
|
|
6211
|
-
// creating the reactive observer for reactive params when needed
|
|
6212
|
-
const ro = createReactiveObserver(() => {
|
|
6213
|
-
if (hasPendingConfig === false) {
|
|
6214
|
-
hasPendingConfig = true;
|
|
6215
|
-
// collect new config in the micro-task
|
|
6216
|
-
Promise.resolve().then(() => {
|
|
6217
|
-
hasPendingConfig = false;
|
|
6218
|
-
// resetting current reactive params
|
|
6219
|
-
ro.reset();
|
|
6220
|
-
// dispatching a new config due to a change in the configuration
|
|
6221
|
-
computeConfigAndUpdate();
|
|
6222
|
-
});
|
|
6223
|
-
}
|
|
6224
|
-
});
|
|
6225
|
-
const computeConfigAndUpdate = () => {
|
|
6226
|
-
let config;
|
|
6227
|
-
ro.observe(() => config = configCallback(component));
|
|
6228
|
-
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
6229
|
-
// TODO: dev-mode validation of config based on the adapter.configSchema
|
|
6230
|
-
// @ts-ignore it is assigned in the observe() callback
|
|
6231
|
-
callbackWhenConfigIsReady(config);
|
|
6232
|
-
};
|
|
6233
|
-
return {
|
|
6234
|
-
computeConfigAndUpdate,
|
|
6235
|
-
ro
|
|
6236
|
-
};
|
|
6237
|
-
}
|
|
6238
|
-
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
6239
|
-
const {
|
|
6240
|
-
adapter
|
|
6241
|
-
} = wireDef;
|
|
6242
|
-
const adapterContextToken = getAdapterToken(adapter);
|
|
6243
|
-
if (isUndefined$1(adapterContextToken)) {
|
|
6244
|
-
return; // no provider found, nothing to be done
|
|
6245
|
-
}
|
|
6246
|
-
|
|
6247
|
-
const {
|
|
6248
|
-
elm,
|
|
6249
|
-
context: {
|
|
6250
|
-
wiredConnecting,
|
|
6251
|
-
wiredDisconnecting
|
|
6252
|
-
},
|
|
6253
|
-
renderer: {
|
|
6254
|
-
dispatchEvent
|
|
6255
|
-
}
|
|
6256
|
-
} = vm;
|
|
6257
|
-
// waiting for the component to be connected to formally request the context via the token
|
|
6258
|
-
ArrayPush$1.call(wiredConnecting, () => {
|
|
6259
|
-
// This event is responsible for connecting the host element with another
|
|
6260
|
-
// element in the composed path that is providing contextual data. The provider
|
|
6261
|
-
// must be listening for a special dom event with the name corresponding to the value of
|
|
6262
|
-
// `adapterContextToken`, which will remain secret and internal to this file only to
|
|
6263
|
-
// guarantee that the linkage can be forged.
|
|
6264
|
-
const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
|
|
6265
|
-
setNewContext(newContext) {
|
|
6266
|
-
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
6267
|
-
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
6268
|
-
callbackWhenContextIsReady(newContext);
|
|
6269
|
-
},
|
|
6270
|
-
setDisconnectedCallback(disconnectCallback) {
|
|
6271
|
-
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
6272
|
-
// the the element hosting the wire is disconnected
|
|
6273
|
-
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
6274
|
-
}
|
|
6275
|
-
});
|
|
6276
|
-
dispatchEvent(elm, contextRegistrationEvent);
|
|
6277
|
-
});
|
|
6278
|
-
}
|
|
6279
|
-
function createConnector(vm, name, wireDef) {
|
|
6280
|
-
const {
|
|
6281
|
-
method,
|
|
6282
|
-
adapter,
|
|
6283
|
-
configCallback,
|
|
6284
|
-
dynamic
|
|
6285
|
-
} = wireDef;
|
|
6286
|
-
let debugInfo;
|
|
6287
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6288
|
-
const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
|
|
6289
|
-
debugInfo = create(null);
|
|
6290
|
-
debugInfo.wasDataProvisionedForConfig = false;
|
|
6291
|
-
vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
|
|
6292
|
-
}
|
|
6293
|
-
const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
6294
|
-
const dataCallback = value => {
|
|
6295
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6296
|
-
debugInfo.data = value;
|
|
6297
|
-
// Note: most of the time, the data provided is for the current config, but there may be
|
|
6298
|
-
// some conditions in which it does not, ex:
|
|
6299
|
-
// race conditions in a poor network while the adapter does not cancel a previous request.
|
|
6300
|
-
debugInfo.wasDataProvisionedForConfig = true;
|
|
6301
|
-
}
|
|
6302
|
-
fieldOrMethodCallback(value);
|
|
6303
|
-
};
|
|
6304
|
-
let context;
|
|
6305
|
-
let connector;
|
|
6306
|
-
// Workaround to pass the component element associated to this wire adapter instance.
|
|
6307
|
-
defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
6308
|
-
value: vm.elm
|
|
6309
|
-
});
|
|
6310
|
-
defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
|
|
6311
|
-
value: dynamic
|
|
6312
|
-
});
|
|
6313
|
-
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
6314
|
-
// job
|
|
6315
|
-
connector = new adapter(dataCallback);
|
|
6316
|
-
}, noop);
|
|
6317
|
-
const updateConnectorConfig = config => {
|
|
6318
|
-
// every time the config is recomputed due to tracking,
|
|
6319
|
-
// this callback will be invoked with the new computed config
|
|
6320
|
-
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
6321
|
-
// job
|
|
6322
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6323
|
-
debugInfo.config = config;
|
|
6324
|
-
debugInfo.context = context;
|
|
6325
|
-
debugInfo.wasDataProvisionedForConfig = false;
|
|
6561
|
+
resetComponentStateWhenRemoved(childVM);
|
|
6326
6562
|
}
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
// If it has params, we will need to observe changes in the next tick.
|
|
6563
|
+
}
|
|
6564
|
+
}
|
|
6565
|
+
}
|
|
6566
|
+
function runLightChildNodesDisconnectedCallback(vm) {
|
|
6332
6567
|
const {
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6568
|
+
aChildren: adoptedChildren
|
|
6569
|
+
} = vm;
|
|
6570
|
+
recursivelyDisconnectChildren(adoptedChildren);
|
|
6571
|
+
}
|
|
6572
|
+
/**
|
|
6573
|
+
* The recursion doesn't need to be a complete traversal of the vnode graph,
|
|
6574
|
+
* instead it can be partial, when a custom element vnode is found, we don't
|
|
6575
|
+
* need to continue into its children because by attempting to disconnect the
|
|
6576
|
+
* custom element itself will trigger the removal of anything slotted or anything
|
|
6577
|
+
* defined on its shadow.
|
|
6578
|
+
*/
|
|
6579
|
+
function recursivelyDisconnectChildren(vnodes) {
|
|
6580
|
+
for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
|
6581
|
+
const vnode = vnodes[i];
|
|
6582
|
+
if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
|
|
6583
|
+
switch (vnode.type) {
|
|
6584
|
+
case 2 /* VNodeType.Element */:
|
|
6585
|
+
recursivelyDisconnectChildren(vnode.children);
|
|
6586
|
+
break;
|
|
6587
|
+
case 3 /* VNodeType.CustomElement */:
|
|
6588
|
+
{
|
|
6589
|
+
const vm = getAssociatedVM(vnode.elm);
|
|
6590
|
+
resetComponentStateWhenRemoved(vm);
|
|
6591
|
+
break;
|
|
6592
|
+
}
|
|
6349
6593
|
}
|
|
6350
|
-
}
|
|
6594
|
+
}
|
|
6351
6595
|
}
|
|
6352
|
-
return {
|
|
6353
|
-
// @ts-ignore the boundary protection executes sync, connector is always defined
|
|
6354
|
-
connector,
|
|
6355
|
-
computeConfigAndUpdate,
|
|
6356
|
-
resetConfigWatcher: () => ro.reset()
|
|
6357
|
-
};
|
|
6358
|
-
}
|
|
6359
|
-
const AdapterToTokenMap = new Map();
|
|
6360
|
-
function getAdapterToken(adapter) {
|
|
6361
|
-
return AdapterToTokenMap.get(adapter);
|
|
6362
6596
|
}
|
|
6363
|
-
|
|
6364
|
-
|
|
6597
|
+
// This is a super optimized mechanism to remove the content of the root node (shadow root
|
|
6598
|
+
// for shadow DOM components and the root element itself for light DOM) without having to go
|
|
6599
|
+
// into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
|
|
6600
|
+
// children VNodes might not be representing the current state of the DOM.
|
|
6601
|
+
function resetComponentRoot(vm) {
|
|
6602
|
+
const {
|
|
6603
|
+
children,
|
|
6604
|
+
renderRoot,
|
|
6605
|
+
renderer: {
|
|
6606
|
+
remove
|
|
6607
|
+
}
|
|
6608
|
+
} = vm;
|
|
6609
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
6610
|
+
const child = children[i];
|
|
6611
|
+
if (!isNull(child) && !isUndefined$1(child.elm)) {
|
|
6612
|
+
remove(child.elm, renderRoot);
|
|
6613
|
+
}
|
|
6614
|
+
}
|
|
6615
|
+
vm.children = EmptyArray;
|
|
6616
|
+
runChildNodesDisconnectedCallback(vm);
|
|
6617
|
+
vm.velements = EmptyArray;
|
|
6365
6618
|
}
|
|
6366
|
-
function
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
adapter = adapter.adapter;
|
|
6619
|
+
function scheduleRehydration(vm) {
|
|
6620
|
+
if (isTrue(vm.isScheduled)) {
|
|
6621
|
+
return;
|
|
6370
6622
|
}
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
dynamic
|
|
6377
|
-
};
|
|
6378
|
-
WireMetaMap.set(descriptor, def);
|
|
6623
|
+
vm.isScheduled = true;
|
|
6624
|
+
if (rehydrateQueue.length === 0) {
|
|
6625
|
+
addCallbackToNextTick(flushRehydrationQueue);
|
|
6626
|
+
}
|
|
6627
|
+
ArrayPush$1.call(rehydrateQueue, vm);
|
|
6379
6628
|
}
|
|
6380
|
-
function
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6629
|
+
function getErrorBoundaryVM(vm) {
|
|
6630
|
+
let currentVm = vm;
|
|
6631
|
+
while (!isNull(currentVm)) {
|
|
6632
|
+
if (!isUndefined$1(currentVm.def.errorCallback)) {
|
|
6633
|
+
return currentVm;
|
|
6634
|
+
}
|
|
6635
|
+
currentVm = currentVm.owner;
|
|
6384
6636
|
}
|
|
6385
|
-
const def = {
|
|
6386
|
-
adapter,
|
|
6387
|
-
configCallback,
|
|
6388
|
-
dynamic
|
|
6389
|
-
};
|
|
6390
|
-
WireMetaMap.set(descriptor, def);
|
|
6391
6637
|
}
|
|
6392
|
-
function
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6638
|
+
function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
|
6639
|
+
let error;
|
|
6640
|
+
pre();
|
|
6641
|
+
try {
|
|
6642
|
+
job();
|
|
6643
|
+
} catch (e) {
|
|
6644
|
+
error = Object(e);
|
|
6645
|
+
} finally {
|
|
6646
|
+
post();
|
|
6647
|
+
if (!isUndefined$1(error)) {
|
|
6648
|
+
addErrorComponentStack(vm, error);
|
|
6649
|
+
const errorBoundaryVm = isNull(owner) ? undefined : getErrorBoundaryVM(owner);
|
|
6650
|
+
if (isUndefined$1(errorBoundaryVm)) {
|
|
6651
|
+
throw error; // eslint-disable-line no-unsafe-finally
|
|
6652
|
+
}
|
|
6653
|
+
|
|
6654
|
+
resetComponentRoot(vm); // remove offenders
|
|
6655
|
+
logOperationStart(6 /* OperationId.ErrorCallback */, vm);
|
|
6656
|
+
// error boundaries must have an ErrorCallback
|
|
6657
|
+
const errorCallback = errorBoundaryVm.def.errorCallback;
|
|
6658
|
+
invokeComponentCallback(errorBoundaryVm, errorCallback, [error, error.wcStack]);
|
|
6659
|
+
logOperationEnd(6 /* OperationId.ErrorCallback */, vm);
|
|
6397
6660
|
}
|
|
6398
|
-
} = vm;
|
|
6399
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6400
|
-
vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
|
|
6401
6661
|
}
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6662
|
+
}
|
|
6663
|
+
function forceRehydration(vm) {
|
|
6664
|
+
// if we must reset the shadowRoot content and render the template
|
|
6665
|
+
// from scratch on an active instance, the way to force the reset
|
|
6666
|
+
// is by replacing the value of old template, which is used during
|
|
6667
|
+
// to determine if the template has changed or not during the rendering
|
|
6668
|
+
// process. If the template returned by render() is different from the
|
|
6669
|
+
// previous stored template, the styles will be reset, along with the
|
|
6670
|
+
// content of the shadowRoot, this way we can guarantee that all children
|
|
6671
|
+
// elements will be throw away, and new instances will be created.
|
|
6672
|
+
vm.cmpTemplate = () => [];
|
|
6673
|
+
if (isFalse(vm.isDirty)) {
|
|
6674
|
+
// forcing the vm to rehydrate in the next tick
|
|
6675
|
+
markComponentAsDirty(vm);
|
|
6676
|
+
scheduleRehydration(vm);
|
|
6677
|
+
}
|
|
6678
|
+
}
|
|
6679
|
+
|
|
6680
|
+
/*
|
|
6681
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6682
|
+
* All rights reserved.
|
|
6683
|
+
* SPDX-License-Identifier: MIT
|
|
6684
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6685
|
+
*/
|
|
6686
|
+
//
|
|
6687
|
+
// The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
|
|
6688
|
+
// These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
|
|
6689
|
+
// When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
|
|
6690
|
+
// See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
|
|
6691
|
+
//
|
|
6692
|
+
// Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
|
|
6693
|
+
const getElementById = _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
|
|
6694
|
+
const querySelectorAll = _globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
|
|
6695
|
+
function isSyntheticShadowRootInstance(rootNode) {
|
|
6696
|
+
return rootNode !== document && isTrue(rootNode.synthetic);
|
|
6697
|
+
}
|
|
6698
|
+
function reportViolation(source, target, attrName) {
|
|
6699
|
+
// The vm is either for the source, the target, or both. Either one or both must be using synthetic
|
|
6700
|
+
// shadow for a violation to be detected.
|
|
6701
|
+
let vm = getAssociatedVMIfPresent(source.getRootNode().host);
|
|
6702
|
+
if (isUndefined$1(vm)) {
|
|
6703
|
+
vm = getAssociatedVMIfPresent(target.getRootNode().host);
|
|
6704
|
+
}
|
|
6705
|
+
if (isUndefined$1(vm)) {
|
|
6706
|
+
// vm should never be undefined here, but just to be safe, bail out and don't report
|
|
6707
|
+
return;
|
|
6708
|
+
}
|
|
6709
|
+
report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
|
|
6407
6710
|
if (process.env.NODE_ENV !== 'production') {
|
|
6408
|
-
|
|
6711
|
+
// Avoid excessively logging to the console in the case of duplicates.
|
|
6712
|
+
logWarnOnce(`Element <${source.tagName.toLowerCase()}> uses attribute "${attrName}" to reference element ` +
|
|
6713
|
+
`<${target.tagName.toLowerCase()}>, which is not in the same shadow root. This will break in native shadow DOM. ` +
|
|
6714
|
+
`For details, see: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates`, vm);
|
|
6409
6715
|
}
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6716
|
+
}
|
|
6717
|
+
function parseIdRefAttributeValue(attrValue) {
|
|
6718
|
+
// split on whitespace and skip empty strings after splitting
|
|
6719
|
+
return isString(attrValue) ? ArrayFilter.call(StringSplit.call(attrValue, /\s+/), Boolean) : [];
|
|
6720
|
+
}
|
|
6721
|
+
function detectSyntheticCrossRootAria(elm, attrName, attrValue) {
|
|
6722
|
+
const root = elm.getRootNode();
|
|
6723
|
+
if (!isSyntheticShadowRootInstance(root)) {
|
|
6724
|
+
return;
|
|
6725
|
+
}
|
|
6726
|
+
if (attrName === 'id') {
|
|
6727
|
+
// elm is the target, find the source
|
|
6728
|
+
if (!isString(attrValue) || attrValue.length === 0) {
|
|
6729
|
+
// if our id is null or empty, nobody can reference us
|
|
6422
6730
|
return;
|
|
6423
|
-
}
|
|
6424
6731
|
}
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6732
|
+
for (const idRefAttrName of ID_REFERENCING_ATTRIBUTES_SET) {
|
|
6733
|
+
// Query all global elements with this attribute. The attribute selector syntax `~=` is for values
|
|
6734
|
+
// that reference multiple IDs, separated by whitespace.
|
|
6735
|
+
const query = `[${idRefAttrName}~="${CSS.escape(attrValue)}"]`;
|
|
6736
|
+
const sourceElements = querySelectorAll.call(document, query);
|
|
6737
|
+
for (let i = 0; i < sourceElements.length; i++) {
|
|
6738
|
+
const sourceElement = sourceElements[i];
|
|
6739
|
+
const sourceRoot = sourceElement.getRootNode();
|
|
6740
|
+
if (sourceRoot !== root) {
|
|
6741
|
+
reportViolation(sourceElement, elm, idRefAttrName);
|
|
6742
|
+
break;
|
|
6743
|
+
}
|
|
6744
|
+
}
|
|
6745
|
+
}
|
|
6746
|
+
}
|
|
6747
|
+
else {
|
|
6748
|
+
// elm is the source, find the target
|
|
6749
|
+
const ids = parseIdRefAttributeValue(attrValue);
|
|
6750
|
+
for (const id of ids) {
|
|
6751
|
+
const target = getElementById.call(document, id);
|
|
6752
|
+
if (!isNull(target)) {
|
|
6753
|
+
const targetRoot = target.getRootNode();
|
|
6754
|
+
if (targetRoot !== root) {
|
|
6755
|
+
// target element's shadow root is not the same as ours
|
|
6756
|
+
reportViolation(elm, target, attrName);
|
|
6757
|
+
}
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6431
6760
|
}
|
|
6432
|
-
}
|
|
6433
6761
|
}
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6762
|
+
let enabled = false;
|
|
6763
|
+
// We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
|
|
6764
|
+
// reporting is not enabled. It should also only run once
|
|
6765
|
+
function enableDetection() {
|
|
6766
|
+
if (enabled) {
|
|
6767
|
+
return; // don't double-apply the patches
|
|
6768
|
+
}
|
|
6769
|
+
enabled = true;
|
|
6770
|
+
const { setAttribute } = Element.prototype;
|
|
6771
|
+
// Detect calling `setAttribute` to set an idref or an id
|
|
6772
|
+
assign(Element.prototype, {
|
|
6773
|
+
setAttribute(attrName, attrValue) {
|
|
6774
|
+
setAttribute.call(this, attrName, attrValue);
|
|
6775
|
+
if (attrName === 'id' || ID_REFERENCING_ATTRIBUTES_SET.has(attrName)) {
|
|
6776
|
+
detectSyntheticCrossRootAria(this, attrName, attrValue);
|
|
6777
|
+
}
|
|
6778
|
+
},
|
|
6779
|
+
});
|
|
6780
|
+
// Detect `elm.id = 'foo'`
|
|
6781
|
+
const idDescriptor = getOwnPropertyDescriptor$1(Element.prototype, 'id');
|
|
6782
|
+
if (!isUndefined$1(idDescriptor)) {
|
|
6783
|
+
const { get, set } = idDescriptor;
|
|
6784
|
+
// These should always be a getter and a setter, but if someone is monkeying with the global descriptor, ignore it
|
|
6785
|
+
if (isFunction$1(get) && isFunction$1(set)) {
|
|
6786
|
+
defineProperty(Element.prototype, 'id', {
|
|
6787
|
+
get() {
|
|
6788
|
+
return get.call(this);
|
|
6789
|
+
},
|
|
6790
|
+
set(value) {
|
|
6791
|
+
set.call(this, value);
|
|
6792
|
+
detectSyntheticCrossRootAria(this, 'id', value);
|
|
6793
|
+
},
|
|
6794
|
+
// On the default descriptor for 'id', enumerable and configurable are true
|
|
6795
|
+
enumerable: true,
|
|
6796
|
+
configurable: true,
|
|
6797
|
+
});
|
|
6798
|
+
}
|
|
6799
|
+
}
|
|
6441
6800
|
}
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6801
|
+
// Our detection logic relies on some modern browser features. We can just skip reporting the data
|
|
6802
|
+
// for unsupported browsers
|
|
6803
|
+
function supportsCssEscape() {
|
|
6804
|
+
return typeof CSS !== 'undefined' && isFunction$1(CSS.escape);
|
|
6805
|
+
}
|
|
6806
|
+
// If this page is not using synthetic shadow, then we don't need to install detection. Note
|
|
6807
|
+
// that we are assuming synthetic shadow is loaded before LWC.
|
|
6808
|
+
function isSyntheticShadowLoaded() {
|
|
6809
|
+
// We should probably be calling `renderer.isSyntheticShadowDefined`, but 1) we don't have access to the renderer,
|
|
6810
|
+
// and 2) this code needs to run in @lwc/engine-core, so it can access `logWarn()` and `report()`.
|
|
6811
|
+
return hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
|
|
6812
|
+
}
|
|
6813
|
+
// Detecting cross-root ARIA in synthetic shadow only makes sense for the browser
|
|
6814
|
+
if (supportsCssEscape() && isSyntheticShadowLoaded()) {
|
|
6815
|
+
// Always run detection in dev mode, so we can at least print to the console
|
|
6816
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6817
|
+
enableDetection();
|
|
6818
|
+
}
|
|
6819
|
+
else {
|
|
6820
|
+
// In prod mode, only enable detection if reporting is enabled
|
|
6821
|
+
onReportingEnabled(enableDetection);
|
|
6450
6822
|
}
|
|
6451
|
-
}, noop);
|
|
6452
6823
|
}
|
|
6453
6824
|
|
|
6454
6825
|
/*
|
|
@@ -7120,7 +7491,7 @@ function getComponentConstructor(elm) {
|
|
|
7120
7491
|
}
|
|
7121
7492
|
return ctor;
|
|
7122
7493
|
}
|
|
7123
|
-
/* version: 2.
|
|
7494
|
+
/* version: 2.35.0 */
|
|
7124
7495
|
|
|
7125
7496
|
/*
|
|
7126
7497
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7227,7 +7598,9 @@ const stylesheetCache = new Map();
|
|
|
7227
7598
|
//
|
|
7228
7599
|
// Test utilities
|
|
7229
7600
|
//
|
|
7230
|
-
|
|
7601
|
+
// Only used in LWC's Karma tests
|
|
7602
|
+
// @ts-ignore
|
|
7603
|
+
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
7231
7604
|
// @ts-ignore
|
|
7232
7605
|
window.__lwcResetGlobalStylesheets = () => {
|
|
7233
7606
|
stylesheetCache.clear();
|
|
@@ -8093,7 +8466,7 @@ function rendererFactory(baseRenderer) {
|
|
|
8093
8466
|
function isNull(obj) {
|
|
8094
8467
|
return obj === null;
|
|
8095
8468
|
}
|
|
8096
|
-
/** version: 2.
|
|
8469
|
+
/** version: 2.35.0 */
|
|
8097
8470
|
|
|
8098
8471
|
/*
|
|
8099
8472
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8654,6 +9027,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
8654
9027
|
});
|
|
8655
9028
|
freeze(LightningElement);
|
|
8656
9029
|
seal(LightningElement.prototype);
|
|
8657
|
-
/* version: 2.
|
|
9030
|
+
/* version: 2.35.0 */
|
|
8658
9031
|
|
|
8659
|
-
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
9032
|
+
export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|