lwc 2.34.0 → 2.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +742 -493
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +742 -492
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +777 -641
  5. package/dist/engine-dom/iife/es5/engine-dom.js +882 -618
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +732 -579
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +742 -492
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +777 -641
  11. package/dist/engine-dom/umd/es5/engine-dom.js +882 -618
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +732 -579
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +635 -603
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +635 -603
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +15 -4
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +15 -4
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +15 -4
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +18 -3
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +18 -3
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +15 -4
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +15 -4
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +18 -3
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +18 -3
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. 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
  }
@@ -188,6 +188,19 @@
188
188
  });
189
189
  return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap };
190
190
  })();
191
+ // These attributes take either an ID or a list of IDs as values.
192
+ // This includes aria-* attributes as well as the special non-ARIA "for" attribute
193
+ const ID_REFERENCING_ATTRIBUTES_SET = new Set([
194
+ 'aria-activedescendant',
195
+ 'aria-controls',
196
+ 'aria-describedby',
197
+ 'aria-details',
198
+ 'aria-errormessage',
199
+ 'aria-flowto',
200
+ 'aria-labelledby',
201
+ 'aria-owns',
202
+ 'for',
203
+ ]);
191
204
 
192
205
  /*
193
206
  * Copyright (c) 2018, salesforce.com, inc.
@@ -243,6 +256,8 @@
243
256
  const KEY__SHADOW_TOKEN = '$shadowToken$';
244
257
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
245
258
  const KEY__SCOPED_CSS = '$scoped$';
259
+ const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
260
+ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
246
261
  const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
247
262
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
248
263
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
@@ -350,9 +365,9 @@
350
365
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
351
366
  */
352
367
  // Increment whenever the LWC template compiler changes
353
- const LWC_VERSION = "2.34.0";
368
+ const LWC_VERSION = "2.35.0";
354
369
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
355
- /** version: 2.34.0 */
370
+ /** version: 2.35.0 */
356
371
 
357
372
  /**
358
373
  * Copyright (C) 2018 salesforce.com, inc.
@@ -429,7 +444,7 @@
429
444
  setFeatureFlag(name, value);
430
445
  }
431
446
  }
432
- /** version: 2.34.0 */
447
+ /** version: 2.35.0 */
433
448
 
434
449
  /**
435
450
  * Copyright (C) 2018 salesforce.com, inc.
@@ -493,7 +508,7 @@
493
508
  }
494
509
  }
495
510
  }
496
- /** version: 2.34.0 */
511
+ /** version: 2.35.0 */
497
512
 
498
513
  /*
499
514
  * Copyright (c) 2018, salesforce.com, inc.
@@ -561,94 +576,167 @@
561
576
  * SPDX-License-Identifier: MIT
562
577
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
563
578
  */
564
- let nextTickCallbackQueue = [];
565
- const SPACE_CHAR = 32;
566
- const EmptyObject = seal(create(null));
567
- const EmptyArray = seal([]);
568
- function flushCallbackQueue() {
569
- if (process.env.NODE_ENV !== 'production') {
570
- if (nextTickCallbackQueue.length === 0) {
571
- throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
579
+ /** Callbacks to invoke when reporting is enabled **/
580
+ const onReportingEnabledCallbacks = [];
581
+ /** The currently assigned reporting dispatcher. */
582
+ let currentDispatcher$1 = noop;
583
+ /**
584
+ * Whether reporting is enabled.
585
+ *
586
+ * Note that this may seem redundant, given you can just check if the currentDispatcher is undefined,
587
+ * but it turns out that Terser only strips out unused code if we use this explicit boolean.
588
+ */
589
+ let enabled$1 = false;
590
+ const reportingControl = {
591
+ /**
592
+ * Attach a new reporting control (aka dispatcher).
593
+ *
594
+ * @param dispatcher - reporting control
595
+ */
596
+ attachDispatcher(dispatcher) {
597
+ enabled$1 = true;
598
+ currentDispatcher$1 = dispatcher;
599
+ for (const callback of onReportingEnabledCallbacks) {
600
+ try {
601
+ callback();
602
+ }
603
+ catch (err) {
604
+ // This should never happen. But if it does, we don't want one callback to cause another to fail
605
+ // eslint-disable-next-line no-console
606
+ console.error('Could not invoke callback', err);
607
+ }
572
608
  }
609
+ onReportingEnabledCallbacks.length = 0; // clear the array
610
+ },
611
+ /**
612
+ * Detach the current reporting control (aka dispatcher).
613
+ */
614
+ detachDispatcher() {
615
+ enabled$1 = false;
616
+ currentDispatcher$1 = noop;
617
+ },
618
+ };
619
+ /**
620
+ * Call a callback when reporting is enabled, or immediately if reporting is already enabled.
621
+ * Will only ever be called once.
622
+ * @param callback
623
+ */
624
+ function onReportingEnabled(callback) {
625
+ if (enabled$1) {
626
+ // call immediately
627
+ callback();
573
628
  }
574
- const callbacks = nextTickCallbackQueue;
575
- nextTickCallbackQueue = []; // reset to a new queue
576
- for (let i = 0, len = callbacks.length; i < len; i += 1) {
577
- callbacks[i]();
629
+ else {
630
+ // call later
631
+ onReportingEnabledCallbacks.push(callback);
578
632
  }
579
633
  }
580
- function addCallbackToNextTick(callback) {
581
- if (process.env.NODE_ENV !== 'production') {
582
- if (!isFunction$1(callback)) {
583
- throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
584
- }
585
- }
586
- if (nextTickCallbackQueue.length === 0) {
587
- Promise.resolve().then(flushCallbackQueue);
634
+ /**
635
+ * Report to the current dispatcher, if there is one.
636
+ * @param reportingEventId
637
+ * @param vm
638
+ */
639
+ function report(reportingEventId, vm) {
640
+ if (enabled$1) {
641
+ currentDispatcher$1(reportingEventId, vm.tagName, vm.idx);
588
642
  }
589
- ArrayPush$1.call(nextTickCallbackQueue, callback);
590
643
  }
591
- function guid() {
592
- function s4() {
593
- return Math.floor((1 + Math.random()) * 0x10000)
594
- .toString(16)
595
- .substring(1);
644
+
645
+ /*
646
+ * Copyright (c) 2018, salesforce.com, inc.
647
+ * All rights reserved.
648
+ * SPDX-License-Identifier: MIT
649
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
650
+ */
651
+ function getComponentTag(vm) {
652
+ return `<${StringToLowerCase.call(vm.tagName)}>`;
653
+ }
654
+ // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
655
+ function getComponentStack(vm) {
656
+ const stack = [];
657
+ let prefix = '';
658
+ while (!isNull(vm.owner)) {
659
+ ArrayPush$1.call(stack, prefix + getComponentTag(vm));
660
+ vm = vm.owner;
661
+ prefix += '\t';
596
662
  }
597
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
663
+ return ArrayJoin.call(stack, '\n');
598
664
  }
599
- // Borrowed from Vue template compiler.
600
- // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
601
- const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
602
- const PROPERTY_DELIMITER = /:(.+)/;
603
- function parseStyleText(cssText) {
604
- const styleMap = {};
605
- const declarations = cssText.split(DECLARATION_DELIMITER);
606
- for (const declaration of declarations) {
607
- if (declaration) {
608
- const [prop, value] = declaration.split(PROPERTY_DELIMITER);
609
- if (prop !== undefined && value !== undefined) {
610
- styleMap[prop.trim()] = value.trim();
611
- }
612
- }
665
+ function getErrorComponentStack(vm) {
666
+ const wcStack = [];
667
+ let currentVm = vm;
668
+ while (!isNull(currentVm)) {
669
+ ArrayPush$1.call(wcStack, getComponentTag(currentVm));
670
+ currentVm = currentVm.owner;
613
671
  }
614
- return styleMap;
672
+ return wcStack.reverse().join('\n\t');
615
673
  }
616
- // Make a shallow copy of an object but omit the given key
617
- function cloneAndOmitKey(object, keyToOmit) {
618
- const result = {};
619
- for (const key of Object.keys(object)) {
620
- if (key !== keyToOmit) {
621
- result[key] = object[key];
622
- }
674
+
675
+ /*
676
+ * Copyright (c) 2018, salesforce.com, inc.
677
+ * All rights reserved.
678
+ * SPDX-License-Identifier: MIT
679
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
680
+ */
681
+ function addErrorComponentStack(vm, error) {
682
+ if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
683
+ const wcStack = getErrorComponentStack(vm);
684
+ defineProperty(error, 'wcStack', {
685
+ get() {
686
+ return wcStack;
687
+ },
688
+ });
623
689
  }
624
- return result;
625
690
  }
626
- function flattenStylesheets(stylesheets) {
627
- const list = [];
628
- for (const stylesheet of stylesheets) {
629
- if (!Array.isArray(stylesheet)) {
630
- list.push(stylesheet);
631
- }
632
- else {
633
- list.push(...flattenStylesheets(stylesheet));
691
+
692
+ /*
693
+ * Copyright (c) 2018, salesforce.com, inc.
694
+ * All rights reserved.
695
+ * SPDX-License-Identifier: MIT
696
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
697
+ */
698
+ const alreadyLoggedMessages = new Set();
699
+ // @ts-ignore
700
+ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
701
+ // @ts-ignore
702
+ window.__lwcResetAlreadyLoggedMessages = () => {
703
+ alreadyLoggedMessages.clear();
704
+ };
705
+ }
706
+ function log(method, message, vm, once) {
707
+ let msg = `[LWC ${method}]: ${message}`;
708
+ if (!isUndefined$1(vm)) {
709
+ msg = `${msg}\n${getComponentStack(vm)}`;
710
+ }
711
+ if (once) {
712
+ if (alreadyLoggedMessages.has(msg)) {
713
+ return;
634
714
  }
715
+ alreadyLoggedMessages.add(msg);
635
716
  }
636
- return list;
637
- }
638
- // Set a ref (lwc:ref) on a VM, from a template API
639
- function setRefVNode(vm, ref, vnode) {
640
- if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
641
- throw new Error('refVNodes must be defined when setting a ref');
717
+ // In Jest tests, reduce the warning and error verbosity by not printing the callstack
718
+ if (process.env.NODE_ENV === 'test') {
719
+ /* eslint-disable-next-line no-console */
720
+ console[method](msg);
721
+ return;
642
722
  }
643
- // If this method is called, then vm.refVNodes is set as the template has refs.
644
- // If not, then something went wrong and we threw an error above.
645
- const refVNodes = vm.refVNodes;
646
- // In cases of conflict (two elements with the same ref), prefer, the last one,
647
- // in depth-first traversal order.
648
- if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
649
- refVNodes[ref] = vnode;
723
+ try {
724
+ throw new Error(msg);
725
+ }
726
+ catch (e) {
727
+ /* eslint-disable-next-line no-console */
728
+ console[method](e);
650
729
  }
651
730
  }
731
+ function logError(message, vm) {
732
+ log('error', message, vm, false);
733
+ }
734
+ function logWarn(message, vm) {
735
+ log('warn', message, vm, false);
736
+ }
737
+ function logWarnOnce(message, vm) {
738
+ log('warn', message, vm, true);
739
+ }
652
740
 
653
741
  /*
654
742
  * Copyright (c) 2019, salesforce.com, inc.
@@ -770,79 +858,95 @@
770
858
  * SPDX-License-Identifier: MIT
771
859
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
772
860
  */
773
- function getComponentTag(vm) {
774
- return `<${StringToLowerCase.call(vm.tagName)}>`;
775
- }
776
- // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
777
- function getComponentStack(vm) {
778
- const stack = [];
779
- let prefix = '';
780
- while (!isNull(vm.owner)) {
781
- ArrayPush$1.call(stack, prefix + getComponentTag(vm));
782
- vm = vm.owner;
783
- prefix += '\t';
784
- }
785
- return ArrayJoin.call(stack, '\n');
786
- }
787
- function getErrorComponentStack(vm) {
788
- const wcStack = [];
789
- let currentVm = vm;
790
- while (!isNull(currentVm)) {
791
- ArrayPush$1.call(wcStack, getComponentTag(currentVm));
792
- currentVm = currentVm.owner;
861
+ let nextTickCallbackQueue = [];
862
+ const SPACE_CHAR = 32;
863
+ const EmptyObject = seal(create(null));
864
+ const EmptyArray = seal([]);
865
+ function flushCallbackQueue() {
866
+ if (process.env.NODE_ENV !== 'production') {
867
+ if (nextTickCallbackQueue.length === 0) {
868
+ throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
869
+ }
793
870
  }
794
- return wcStack.reverse().join('\n\t');
795
- }
796
-
797
- /*
798
- * Copyright (c) 2018, salesforce.com, inc.
799
- * All rights reserved.
800
- * SPDX-License-Identifier: MIT
801
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
802
- */
803
- function addErrorComponentStack(vm, error) {
804
- if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
805
- const wcStack = getErrorComponentStack(vm);
806
- defineProperty(error, 'wcStack', {
807
- get() {
808
- return wcStack;
809
- },
810
- });
871
+ const callbacks = nextTickCallbackQueue;
872
+ nextTickCallbackQueue = []; // reset to a new queue
873
+ for (let i = 0, len = callbacks.length; i < len; i += 1) {
874
+ callbacks[i]();
811
875
  }
812
876
  }
813
-
814
- /*
815
- * Copyright (c) 2018, salesforce.com, inc.
816
- * All rights reserved.
817
- * SPDX-License-Identifier: MIT
818
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
819
- */
820
- function log(method, message, vm) {
821
- let msg = `[LWC ${method}]: ${message}`;
822
- if (!isUndefined$1(vm)) {
823
- msg = `${msg}\n${getComponentStack(vm)}`;
824
- }
825
- // In Jest tests, reduce the warning and error verbosity by not printing the callstack
826
- if (process.env.NODE_ENV === 'test') {
827
- /* eslint-disable-next-line no-console */
828
- console[method](msg);
829
- return;
830
- }
831
- try {
832
- throw new Error(msg);
877
+ function addCallbackToNextTick(callback) {
878
+ if (process.env.NODE_ENV !== 'production') {
879
+ if (!isFunction$1(callback)) {
880
+ throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
881
+ }
833
882
  }
834
- catch (e) {
835
- /* eslint-disable-next-line no-console */
836
- console[method](e);
883
+ if (nextTickCallbackQueue.length === 0) {
884
+ Promise.resolve().then(flushCallbackQueue);
837
885
  }
886
+ ArrayPush$1.call(nextTickCallbackQueue, callback);
838
887
  }
839
- function logError(message, vm) {
840
- log('error', message, vm);
841
- }
842
- function logWarn(message, vm) {
843
- log('warn', message, vm);
888
+ function guid() {
889
+ function s4() {
890
+ return Math.floor((1 + Math.random()) * 0x10000)
891
+ .toString(16)
892
+ .substring(1);
893
+ }
894
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
844
895
  }
845
-
896
+ // Borrowed from Vue template compiler.
897
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
898
+ const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
899
+ const PROPERTY_DELIMITER = /:(.+)/;
900
+ function parseStyleText(cssText) {
901
+ const styleMap = {};
902
+ const declarations = cssText.split(DECLARATION_DELIMITER);
903
+ for (const declaration of declarations) {
904
+ if (declaration) {
905
+ const [prop, value] = declaration.split(PROPERTY_DELIMITER);
906
+ if (prop !== undefined && value !== undefined) {
907
+ styleMap[prop.trim()] = value.trim();
908
+ }
909
+ }
910
+ }
911
+ return styleMap;
912
+ }
913
+ // Make a shallow copy of an object but omit the given key
914
+ function cloneAndOmitKey(object, keyToOmit) {
915
+ const result = {};
916
+ for (const key of Object.keys(object)) {
917
+ if (key !== keyToOmit) {
918
+ result[key] = object[key];
919
+ }
920
+ }
921
+ return result;
922
+ }
923
+ function flattenStylesheets(stylesheets) {
924
+ const list = [];
925
+ for (const stylesheet of stylesheets) {
926
+ if (!Array.isArray(stylesheet)) {
927
+ list.push(stylesheet);
928
+ }
929
+ else {
930
+ list.push(...flattenStylesheets(stylesheet));
931
+ }
932
+ }
933
+ return list;
934
+ }
935
+ // Set a ref (lwc:ref) on a VM, from a template API
936
+ function setRefVNode(vm, ref, vnode) {
937
+ if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
938
+ throw new Error('refVNodes must be defined when setting a ref');
939
+ }
940
+ // If this method is called, then vm.refVNodes is set as the template has refs.
941
+ // If not, then something went wrong and we threw an error above.
942
+ const refVNodes = vm.refVNodes;
943
+ // In cases of conflict (two elements with the same ref), prefer, the last one,
944
+ // in depth-first traversal order.
945
+ if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
946
+ refVNodes[ref] = vnode;
947
+ }
948
+ }
949
+
846
950
  /*
847
951
  * Copyright (c) 2020, salesforce.com, inc.
848
952
  * All rights reserved.
@@ -895,7 +999,7 @@
895
999
  //
896
1000
  // If you update this list, check for test files that recapitulate the same list. Searching the codebase
897
1001
  // for e.g. "dropzone" should suffice.
898
- const globalHTMLProperties = assign(create(null), {
1002
+ const globalHTMLProperties = {
899
1003
  accessKey: {
900
1004
  attribute: 'accesskey',
901
1005
  },
@@ -980,7 +1084,7 @@
980
1084
  role: {
981
1085
  attribute: 'role',
982
1086
  },
983
- });
1087
+ };
984
1088
  let controlledElement = null;
985
1089
  let controlledAttributeName;
986
1090
  function isAttributeLocked(elm, attrName) {
@@ -2442,92 +2546,380 @@
2442
2546
  * SPDX-License-Identifier: MIT
2443
2547
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2444
2548
  */
2445
- function api$1() {
2446
- if (process.env.NODE_ENV !== 'production') {
2447
- assert.fail(`@api decorator can only be used as a decorator function.`);
2448
- }
2449
- throw new Error();
2549
+ const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
2550
+ const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
2551
+ const WIRE_DEBUG_ENTRY = '@wire';
2552
+ const WireMetaMap = new Map();
2553
+ class WireContextRegistrationEvent extends CustomEvent {
2554
+ constructor(adapterToken, {
2555
+ setNewContext,
2556
+ setDisconnectedCallback
2557
+ }) {
2558
+ super(adapterToken, {
2559
+ bubbles: true,
2560
+ composed: true
2561
+ });
2562
+ defineProperties(this, {
2563
+ setNewContext: {
2564
+ value: setNewContext
2565
+ },
2566
+ setDisconnectedCallback: {
2567
+ value: setDisconnectedCallback
2568
+ }
2569
+ });
2570
+ }
2450
2571
  }
2451
- function createPublicPropertyDescriptor(key) {
2452
- return {
2453
- get() {
2454
- const vm = getAssociatedVM(this);
2455
- if (isBeingConstructed(vm)) {
2456
- if (process.env.NODE_ENV !== 'production') {
2457
- 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);
2458
- }
2459
- return;
2460
- }
2461
- componentValueObserved(vm, key);
2462
- return vm.cmpProps[key];
2463
- },
2464
- set(newValue) {
2465
- const vm = getAssociatedVM(this);
2466
- if (process.env.NODE_ENV !== 'production') {
2467
- const vmBeingRendered = getVMBeingRendered();
2468
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2469
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2470
- }
2471
- vm.cmpProps[key] = newValue;
2472
- componentValueMutated(vm, key);
2473
- },
2474
- enumerable: true,
2475
- configurable: true,
2476
- };
2572
+ function createFieldDataCallback(vm, name) {
2573
+ return value => {
2574
+ updateComponentValue(vm, name, value);
2575
+ };
2477
2576
  }
2478
- function createPublicAccessorDescriptor(key, descriptor) {
2479
- const { get, set, enumerable, configurable } = descriptor;
2480
- if (!isFunction$1(get)) {
2481
- if (process.env.NODE_ENV !== 'production') {
2482
- assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
2483
- }
2484
- throw new Error();
2577
+ function createMethodDataCallback(vm, method) {
2578
+ return value => {
2579
+ // dispatching new value into the wired method
2580
+ runWithBoundaryProtection(vm, vm.owner, noop, () => {
2581
+ // job
2582
+ method.call(vm.component, value);
2583
+ }, noop);
2584
+ };
2585
+ }
2586
+ function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
2587
+ let hasPendingConfig = false;
2588
+ // creating the reactive observer for reactive params when needed
2589
+ const ro = createReactiveObserver(() => {
2590
+ if (hasPendingConfig === false) {
2591
+ hasPendingConfig = true;
2592
+ // collect new config in the micro-task
2593
+ Promise.resolve().then(() => {
2594
+ hasPendingConfig = false;
2595
+ // resetting current reactive params
2596
+ ro.reset();
2597
+ // dispatching a new config due to a change in the configuration
2598
+ computeConfigAndUpdate();
2599
+ });
2485
2600
  }
2486
- return {
2487
- get() {
2488
- if (process.env.NODE_ENV !== 'production') {
2489
- // Assert that the this value is an actual Component with an associated VM.
2490
- getAssociatedVM(this);
2491
- }
2492
- return get.call(this);
2493
- },
2494
- set(newValue) {
2495
- const vm = getAssociatedVM(this);
2496
- if (process.env.NODE_ENV !== 'production') {
2497
- const vmBeingRendered = getVMBeingRendered();
2498
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2499
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2500
- }
2501
- if (set) {
2502
- set.call(this, newValue);
2503
- }
2504
- else if (process.env.NODE_ENV !== 'production') {
2505
- 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.`);
2506
- }
2507
- },
2508
- enumerable,
2509
- configurable,
2510
- };
2601
+ });
2602
+ const computeConfigAndUpdate = () => {
2603
+ let config;
2604
+ ro.observe(() => config = configCallback(component));
2605
+ // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
2606
+ // TODO: dev-mode validation of config based on the adapter.configSchema
2607
+ // @ts-ignore it is assigned in the observe() callback
2608
+ callbackWhenConfigIsReady(config);
2609
+ };
2610
+ return {
2611
+ computeConfigAndUpdate,
2612
+ ro
2613
+ };
2511
2614
  }
2615
+ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
2616
+ const {
2617
+ adapter
2618
+ } = wireDef;
2619
+ const adapterContextToken = getAdapterToken(adapter);
2620
+ if (isUndefined$1(adapterContextToken)) {
2621
+ return; // no provider found, nothing to be done
2622
+ }
2512
2623
 
2513
- /*
2514
- * Copyright (c) 2018, salesforce.com, inc.
2515
- * All rights reserved.
2516
- * SPDX-License-Identifier: MIT
2517
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2518
- */
2519
- function track(target) {
2520
- if (arguments.length === 1) {
2521
- return getReactiveProxy(target);
2624
+ const {
2625
+ elm,
2626
+ context: {
2627
+ wiredConnecting,
2628
+ wiredDisconnecting
2629
+ },
2630
+ renderer: {
2631
+ dispatchEvent
2522
2632
  }
2633
+ } = vm;
2634
+ // waiting for the component to be connected to formally request the context via the token
2635
+ ArrayPush$1.call(wiredConnecting, () => {
2636
+ // This event is responsible for connecting the host element with another
2637
+ // element in the composed path that is providing contextual data. The provider
2638
+ // must be listening for a special dom event with the name corresponding to the value of
2639
+ // `adapterContextToken`, which will remain secret and internal to this file only to
2640
+ // guarantee that the linkage can be forged.
2641
+ const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
2642
+ setNewContext(newContext) {
2643
+ // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
2644
+ // TODO: dev-mode validation of config based on the adapter.contextSchema
2645
+ callbackWhenContextIsReady(newContext);
2646
+ },
2647
+ setDisconnectedCallback(disconnectCallback) {
2648
+ // adds this callback into the disconnect bucket so it gets disconnected from parent
2649
+ // the the element hosting the wire is disconnected
2650
+ ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
2651
+ }
2652
+ });
2653
+ dispatchEvent(elm, contextRegistrationEvent);
2654
+ });
2655
+ }
2656
+ function createConnector(vm, name, wireDef) {
2657
+ const {
2658
+ method,
2659
+ adapter,
2660
+ configCallback,
2661
+ dynamic
2662
+ } = wireDef;
2663
+ let debugInfo;
2664
+ if (process.env.NODE_ENV !== 'production') {
2665
+ const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
2666
+ debugInfo = create(null);
2667
+ debugInfo.wasDataProvisionedForConfig = false;
2668
+ vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
2669
+ }
2670
+ const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
2671
+ const dataCallback = value => {
2523
2672
  if (process.env.NODE_ENV !== 'production') {
2524
- assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
2673
+ debugInfo.data = value;
2674
+ // Note: most of the time, the data provided is for the current config, but there may be
2675
+ // some conditions in which it does not, ex:
2676
+ // race conditions in a poor network while the adapter does not cancel a previous request.
2677
+ debugInfo.wasDataProvisionedForConfig = true;
2525
2678
  }
2526
- throw new Error();
2527
- }
2528
- function internalTrackDecorator(key) {
2529
- return {
2530
- get() {
2679
+ fieldOrMethodCallback(value);
2680
+ };
2681
+ let context;
2682
+ let connector;
2683
+ // Workaround to pass the component element associated to this wire adapter instance.
2684
+ defineProperty(dataCallback, DeprecatedWiredElementHost, {
2685
+ value: vm.elm
2686
+ });
2687
+ defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
2688
+ value: dynamic
2689
+ });
2690
+ runWithBoundaryProtection(vm, vm, noop, () => {
2691
+ // job
2692
+ connector = new adapter(dataCallback);
2693
+ }, noop);
2694
+ const updateConnectorConfig = config => {
2695
+ // every time the config is recomputed due to tracking,
2696
+ // this callback will be invoked with the new computed config
2697
+ runWithBoundaryProtection(vm, vm, noop, () => {
2698
+ // job
2699
+ if (process.env.NODE_ENV !== 'production') {
2700
+ debugInfo.config = config;
2701
+ debugInfo.context = context;
2702
+ debugInfo.wasDataProvisionedForConfig = false;
2703
+ }
2704
+ connector.update(config, context);
2705
+ }, noop);
2706
+ };
2707
+ // Computes the current wire config and calls the update method on the wire adapter.
2708
+ // If it has params, we will need to observe changes in the next tick.
2709
+ const {
2710
+ computeConfigAndUpdate,
2711
+ ro
2712
+ } = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
2713
+ // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
2714
+ if (!isUndefined$1(adapter.contextSchema)) {
2715
+ createContextWatcher(vm, wireDef, newContext => {
2716
+ // every time the context is pushed into this component,
2717
+ // this callback will be invoked with the new computed context
2718
+ if (context !== newContext) {
2719
+ context = newContext;
2720
+ // Note: when new context arrives, the config will be recomputed and pushed along side the new
2721
+ // context, this is to preserve the identity characteristics, config should not have identity
2722
+ // (ever), while context can have identity
2723
+ if (vm.state === 1 /* VMState.connected */) {
2724
+ computeConfigAndUpdate();
2725
+ }
2726
+ }
2727
+ });
2728
+ }
2729
+ return {
2730
+ // @ts-ignore the boundary protection executes sync, connector is always defined
2731
+ connector,
2732
+ computeConfigAndUpdate,
2733
+ resetConfigWatcher: () => ro.reset()
2734
+ };
2735
+ }
2736
+ const AdapterToTokenMap = new Map();
2737
+ function getAdapterToken(adapter) {
2738
+ return AdapterToTokenMap.get(adapter);
2739
+ }
2740
+ function setAdapterToken(adapter, token) {
2741
+ AdapterToTokenMap.set(adapter, token);
2742
+ }
2743
+ function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
2744
+ // support for callable adapters
2745
+ if (adapter.adapter) {
2746
+ adapter = adapter.adapter;
2747
+ }
2748
+ const method = descriptor.value;
2749
+ const def = {
2750
+ adapter,
2751
+ method,
2752
+ configCallback,
2753
+ dynamic
2754
+ };
2755
+ WireMetaMap.set(descriptor, def);
2756
+ }
2757
+ function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
2758
+ // support for callable adapters
2759
+ if (adapter.adapter) {
2760
+ adapter = adapter.adapter;
2761
+ }
2762
+ const def = {
2763
+ adapter,
2764
+ configCallback,
2765
+ dynamic
2766
+ };
2767
+ WireMetaMap.set(descriptor, def);
2768
+ }
2769
+ function installWireAdapters(vm) {
2770
+ const {
2771
+ context,
2772
+ def: {
2773
+ wire
2774
+ }
2775
+ } = vm;
2776
+ if (process.env.NODE_ENV !== 'production') {
2777
+ vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
2778
+ }
2779
+ const wiredConnecting = context.wiredConnecting = [];
2780
+ const wiredDisconnecting = context.wiredDisconnecting = [];
2781
+ for (const fieldNameOrMethod in wire) {
2782
+ const descriptor = wire[fieldNameOrMethod];
2783
+ const wireDef = WireMetaMap.get(descriptor);
2784
+ if (process.env.NODE_ENV !== 'production') {
2785
+ assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
2786
+ }
2787
+ if (!isUndefined$1(wireDef)) {
2788
+ const {
2789
+ connector,
2790
+ computeConfigAndUpdate,
2791
+ resetConfigWatcher
2792
+ } = createConnector(vm, fieldNameOrMethod, wireDef);
2793
+ const hasDynamicParams = wireDef.dynamic.length > 0;
2794
+ ArrayPush$1.call(wiredConnecting, () => {
2795
+ connector.connect();
2796
+ if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
2797
+ if (hasDynamicParams) {
2798
+ Promise.resolve().then(computeConfigAndUpdate);
2799
+ return;
2800
+ }
2801
+ }
2802
+ computeConfigAndUpdate();
2803
+ });
2804
+ ArrayPush$1.call(wiredDisconnecting, () => {
2805
+ connector.disconnect();
2806
+ resetConfigWatcher();
2807
+ });
2808
+ }
2809
+ }
2810
+ }
2811
+ function connectWireAdapters(vm) {
2812
+ const {
2813
+ wiredConnecting
2814
+ } = vm.context;
2815
+ for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
2816
+ wiredConnecting[i]();
2817
+ }
2818
+ }
2819
+ function disconnectWireAdapters(vm) {
2820
+ const {
2821
+ wiredDisconnecting
2822
+ } = vm.context;
2823
+ runWithBoundaryProtection(vm, vm, noop, () => {
2824
+ // job
2825
+ for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
2826
+ wiredDisconnecting[i]();
2827
+ }
2828
+ }, noop);
2829
+ }
2830
+
2831
+ /*
2832
+ * Copyright (c) 2018, salesforce.com, inc.
2833
+ * All rights reserved.
2834
+ * SPDX-License-Identifier: MIT
2835
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2836
+ */
2837
+ function api$1() {
2838
+ if (process.env.NODE_ENV !== 'production') {
2839
+ assert.fail(`@api decorator can only be used as a decorator function.`);
2840
+ }
2841
+ throw new Error();
2842
+ }
2843
+ function createPublicPropertyDescriptor(key) {
2844
+ return {
2845
+ get() {
2846
+ const vm = getAssociatedVM(this);
2847
+ if (isBeingConstructed(vm)) {
2848
+ if (process.env.NODE_ENV !== 'production') {
2849
+ 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);
2850
+ }
2851
+ return;
2852
+ }
2853
+ componentValueObserved(vm, key);
2854
+ return vm.cmpProps[key];
2855
+ },
2856
+ set(newValue) {
2857
+ const vm = getAssociatedVM(this);
2858
+ if (process.env.NODE_ENV !== 'production') {
2859
+ const vmBeingRendered = getVMBeingRendered();
2860
+ assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2861
+ assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2862
+ }
2863
+ vm.cmpProps[key] = newValue;
2864
+ componentValueMutated(vm, key);
2865
+ },
2866
+ enumerable: true,
2867
+ configurable: true,
2868
+ };
2869
+ }
2870
+ function createPublicAccessorDescriptor(key, descriptor) {
2871
+ const { get, set, enumerable, configurable } = descriptor;
2872
+ if (!isFunction$1(get)) {
2873
+ if (process.env.NODE_ENV !== 'production') {
2874
+ assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
2875
+ }
2876
+ throw new Error();
2877
+ }
2878
+ return {
2879
+ get() {
2880
+ if (process.env.NODE_ENV !== 'production') {
2881
+ // Assert that the this value is an actual Component with an associated VM.
2882
+ getAssociatedVM(this);
2883
+ }
2884
+ return get.call(this);
2885
+ },
2886
+ set(newValue) {
2887
+ const vm = getAssociatedVM(this);
2888
+ if (process.env.NODE_ENV !== 'production') {
2889
+ const vmBeingRendered = getVMBeingRendered();
2890
+ assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2891
+ assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2892
+ }
2893
+ if (set) {
2894
+ set.call(this, newValue);
2895
+ }
2896
+ else if (process.env.NODE_ENV !== 'production') {
2897
+ 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.`);
2898
+ }
2899
+ },
2900
+ enumerable,
2901
+ configurable,
2902
+ };
2903
+ }
2904
+
2905
+ /*
2906
+ * Copyright (c) 2018, salesforce.com, inc.
2907
+ * All rights reserved.
2908
+ * SPDX-License-Identifier: MIT
2909
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2910
+ */
2911
+ function track(target) {
2912
+ if (arguments.length === 1) {
2913
+ return getReactiveProxy(target);
2914
+ }
2915
+ if (process.env.NODE_ENV !== 'production') {
2916
+ assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
2917
+ }
2918
+ throw new Error();
2919
+ }
2920
+ function internalTrackDecorator(key) {
2921
+ return {
2922
+ get() {
2531
2923
  const vm = getAssociatedVM(this);
2532
2924
  componentValueObserved(vm, key);
2533
2925
  return vm.cmpFields[key];
@@ -6297,286 +6689,143 @@
6297
6689
  * SPDX-License-Identifier: MIT
6298
6690
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6299
6691
  */
6300
- const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
6301
- const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
6302
- const WIRE_DEBUG_ENTRY = '@wire';
6303
- const WireMetaMap = new Map();
6304
- class WireContextRegistrationEvent extends CustomEvent {
6305
- constructor(adapterToken, {
6306
- setNewContext,
6307
- setDisconnectedCallback
6308
- }) {
6309
- super(adapterToken, {
6310
- bubbles: true,
6311
- composed: true
6312
- });
6313
- defineProperties(this, {
6314
- setNewContext: {
6315
- value: setNewContext
6316
- },
6317
- setDisconnectedCallback: {
6318
- value: setDisconnectedCallback
6319
- }
6320
- });
6321
- }
6322
- }
6323
- function createFieldDataCallback(vm, name) {
6324
- return value => {
6325
- updateComponentValue(vm, name, value);
6326
- };
6692
+ //
6693
+ // The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
6694
+ // These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
6695
+ // When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
6696
+ // See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
6697
+ //
6698
+ // Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
6699
+ const getElementById = _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
6700
+ const querySelectorAll = _globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
6701
+ function isSyntheticShadowRootInstance(rootNode) {
6702
+ return rootNode !== document && isTrue(rootNode.synthetic);
6703
+ }
6704
+ function reportViolation(source, target, attrName) {
6705
+ // The vm is either for the source, the target, or both. Either one or both must be using synthetic
6706
+ // shadow for a violation to be detected.
6707
+ let vm = getAssociatedVMIfPresent(source.getRootNode().host);
6708
+ if (isUndefined$1(vm)) {
6709
+ vm = getAssociatedVMIfPresent(target.getRootNode().host);
6710
+ }
6711
+ if (isUndefined$1(vm)) {
6712
+ // vm should never be undefined here, but just to be safe, bail out and don't report
6713
+ return;
6714
+ }
6715
+ report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
6716
+ if (process.env.NODE_ENV !== 'production') {
6717
+ // Avoid excessively logging to the console in the case of duplicates.
6718
+ logWarnOnce(`Element <${source.tagName.toLowerCase()}> uses attribute "${attrName}" to reference element ` +
6719
+ `<${target.tagName.toLowerCase()}>, which is not in the same shadow root. This will break in native shadow DOM. ` +
6720
+ `For details, see: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates`, vm);
6721
+ }
6327
6722
  }
6328
- function createMethodDataCallback(vm, method) {
6329
- return value => {
6330
- // dispatching new value into the wired method
6331
- runWithBoundaryProtection(vm, vm.owner, noop, () => {
6332
- // job
6333
- method.call(vm.component, value);
6334
- }, noop);
6335
- };
6723
+ function parseIdRefAttributeValue(attrValue) {
6724
+ // split on whitespace and skip empty strings after splitting
6725
+ return isString(attrValue) ? ArrayFilter.call(StringSplit.call(attrValue, /\s+/), Boolean) : [];
6336
6726
  }
6337
- function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
6338
- let hasPendingConfig = false;
6339
- // creating the reactive observer for reactive params when needed
6340
- const ro = createReactiveObserver(() => {
6341
- if (hasPendingConfig === false) {
6342
- hasPendingConfig = true;
6343
- // collect new config in the micro-task
6344
- Promise.resolve().then(() => {
6345
- hasPendingConfig = false;
6346
- // resetting current reactive params
6347
- ro.reset();
6348
- // dispatching a new config due to a change in the configuration
6349
- computeConfigAndUpdate();
6350
- });
6727
+ function detectSyntheticCrossRootAria(elm, attrName, attrValue) {
6728
+ const root = elm.getRootNode();
6729
+ if (!isSyntheticShadowRootInstance(root)) {
6730
+ return;
6351
6731
  }
6352
- });
6353
- const computeConfigAndUpdate = () => {
6354
- let config;
6355
- ro.observe(() => config = configCallback(component));
6356
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
6357
- // TODO: dev-mode validation of config based on the adapter.configSchema
6358
- // @ts-ignore it is assigned in the observe() callback
6359
- callbackWhenConfigIsReady(config);
6360
- };
6361
- return {
6362
- computeConfigAndUpdate,
6363
- ro
6364
- };
6365
- }
6366
- function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
6367
- const {
6368
- adapter
6369
- } = wireDef;
6370
- const adapterContextToken = getAdapterToken(adapter);
6371
- if (isUndefined$1(adapterContextToken)) {
6372
- return; // no provider found, nothing to be done
6373
- }
6374
-
6375
- const {
6376
- elm,
6377
- context: {
6378
- wiredConnecting,
6379
- wiredDisconnecting
6380
- },
6381
- renderer: {
6382
- dispatchEvent
6732
+ if (attrName === 'id') {
6733
+ // elm is the target, find the source
6734
+ if (!isString(attrValue) || attrValue.length === 0) {
6735
+ // if our id is null or empty, nobody can reference us
6736
+ return;
6737
+ }
6738
+ for (const idRefAttrName of ID_REFERENCING_ATTRIBUTES_SET) {
6739
+ // Query all global elements with this attribute. The attribute selector syntax `~=` is for values
6740
+ // that reference multiple IDs, separated by whitespace.
6741
+ const query = `[${idRefAttrName}~="${CSS.escape(attrValue)}"]`;
6742
+ const sourceElements = querySelectorAll.call(document, query);
6743
+ for (let i = 0; i < sourceElements.length; i++) {
6744
+ const sourceElement = sourceElements[i];
6745
+ const sourceRoot = sourceElement.getRootNode();
6746
+ if (sourceRoot !== root) {
6747
+ reportViolation(sourceElement, elm, idRefAttrName);
6748
+ break;
6749
+ }
6750
+ }
6751
+ }
6752
+ }
6753
+ else {
6754
+ // elm is the source, find the target
6755
+ const ids = parseIdRefAttributeValue(attrValue);
6756
+ for (const id of ids) {
6757
+ const target = getElementById.call(document, id);
6758
+ if (!isNull(target)) {
6759
+ const targetRoot = target.getRootNode();
6760
+ if (targetRoot !== root) {
6761
+ // target element's shadow root is not the same as ours
6762
+ reportViolation(elm, target, attrName);
6763
+ }
6764
+ }
6765
+ }
6383
6766
  }
6384
- } = vm;
6385
- // waiting for the component to be connected to formally request the context via the token
6386
- ArrayPush$1.call(wiredConnecting, () => {
6387
- // This event is responsible for connecting the host element with another
6388
- // element in the composed path that is providing contextual data. The provider
6389
- // must be listening for a special dom event with the name corresponding to the value of
6390
- // `adapterContextToken`, which will remain secret and internal to this file only to
6391
- // guarantee that the linkage can be forged.
6392
- const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
6393
- setNewContext(newContext) {
6394
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
6395
- // TODO: dev-mode validation of config based on the adapter.contextSchema
6396
- callbackWhenContextIsReady(newContext);
6397
- },
6398
- setDisconnectedCallback(disconnectCallback) {
6399
- // adds this callback into the disconnect bucket so it gets disconnected from parent
6400
- // the the element hosting the wire is disconnected
6401
- ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
6402
- }
6403
- });
6404
- dispatchEvent(elm, contextRegistrationEvent);
6405
- });
6406
6767
  }
6407
- function createConnector(vm, name, wireDef) {
6408
- const {
6409
- method,
6410
- adapter,
6411
- configCallback,
6412
- dynamic
6413
- } = wireDef;
6414
- let debugInfo;
6415
- if (process.env.NODE_ENV !== 'production') {
6416
- const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
6417
- debugInfo = create(null);
6418
- debugInfo.wasDataProvisionedForConfig = false;
6419
- vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
6420
- }
6421
- const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
6422
- const dataCallback = value => {
6423
- if (process.env.NODE_ENV !== 'production') {
6424
- debugInfo.data = value;
6425
- // Note: most of the time, the data provided is for the current config, but there may be
6426
- // some conditions in which it does not, ex:
6427
- // race conditions in a poor network while the adapter does not cancel a previous request.
6428
- debugInfo.wasDataProvisionedForConfig = true;
6768
+ let enabled = false;
6769
+ // We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
6770
+ // reporting is not enabled. It should also only run once
6771
+ function enableDetection() {
6772
+ if (enabled) {
6773
+ return; // don't double-apply the patches
6429
6774
  }
6430
- fieldOrMethodCallback(value);
6431
- };
6432
- let context;
6433
- let connector;
6434
- // Workaround to pass the component element associated to this wire adapter instance.
6435
- defineProperty(dataCallback, DeprecatedWiredElementHost, {
6436
- value: vm.elm
6437
- });
6438
- defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
6439
- value: dynamic
6440
- });
6441
- runWithBoundaryProtection(vm, vm, noop, () => {
6442
- // job
6443
- connector = new adapter(dataCallback);
6444
- }, noop);
6445
- const updateConnectorConfig = config => {
6446
- // every time the config is recomputed due to tracking,
6447
- // this callback will be invoked with the new computed config
6448
- runWithBoundaryProtection(vm, vm, noop, () => {
6449
- // job
6450
- if (process.env.NODE_ENV !== 'production') {
6451
- debugInfo.config = config;
6452
- debugInfo.context = context;
6453
- debugInfo.wasDataProvisionedForConfig = false;
6454
- }
6455
- connector.update(config, context);
6456
- }, noop);
6457
- };
6458
- // Computes the current wire config and calls the update method on the wire adapter.
6459
- // If it has params, we will need to observe changes in the next tick.
6460
- const {
6461
- computeConfigAndUpdate,
6462
- ro
6463
- } = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
6464
- // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
6465
- if (!isUndefined$1(adapter.contextSchema)) {
6466
- createContextWatcher(vm, wireDef, newContext => {
6467
- // every time the context is pushed into this component,
6468
- // this callback will be invoked with the new computed context
6469
- if (context !== newContext) {
6470
- context = newContext;
6471
- // Note: when new context arrives, the config will be recomputed and pushed along side the new
6472
- // context, this is to preserve the identity characteristics, config should not have identity
6473
- // (ever), while context can have identity
6474
- if (vm.state === 1 /* VMState.connected */) {
6475
- computeConfigAndUpdate();
6476
- }
6477
- }
6775
+ enabled = true;
6776
+ const { setAttribute } = Element.prototype;
6777
+ // Detect calling `setAttribute` to set an idref or an id
6778
+ assign(Element.prototype, {
6779
+ setAttribute(attrName, attrValue) {
6780
+ setAttribute.call(this, attrName, attrValue);
6781
+ if (attrName === 'id' || ID_REFERENCING_ATTRIBUTES_SET.has(attrName)) {
6782
+ detectSyntheticCrossRootAria(this, attrName, attrValue);
6783
+ }
6784
+ },
6478
6785
  });
6479
- }
6480
- return {
6481
- // @ts-ignore the boundary protection executes sync, connector is always defined
6482
- connector,
6483
- computeConfigAndUpdate,
6484
- resetConfigWatcher: () => ro.reset()
6485
- };
6486
- }
6487
- const AdapterToTokenMap = new Map();
6488
- function getAdapterToken(adapter) {
6489
- return AdapterToTokenMap.get(adapter);
6490
- }
6491
- function setAdapterToken(adapter, token) {
6492
- AdapterToTokenMap.set(adapter, token);
6786
+ // Detect `elm.id = 'foo'`
6787
+ const idDescriptor = getOwnPropertyDescriptor$1(Element.prototype, 'id');
6788
+ if (!isUndefined$1(idDescriptor)) {
6789
+ const { get, set } = idDescriptor;
6790
+ // These should always be a getter and a setter, but if someone is monkeying with the global descriptor, ignore it
6791
+ if (isFunction$1(get) && isFunction$1(set)) {
6792
+ defineProperty(Element.prototype, 'id', {
6793
+ get() {
6794
+ return get.call(this);
6795
+ },
6796
+ set(value) {
6797
+ set.call(this, value);
6798
+ detectSyntheticCrossRootAria(this, 'id', value);
6799
+ },
6800
+ // On the default descriptor for 'id', enumerable and configurable are true
6801
+ enumerable: true,
6802
+ configurable: true,
6803
+ });
6804
+ }
6805
+ }
6493
6806
  }
6494
- function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
6495
- // support for callable adapters
6496
- if (adapter.adapter) {
6497
- adapter = adapter.adapter;
6498
- }
6499
- const method = descriptor.value;
6500
- const def = {
6501
- adapter,
6502
- method,
6503
- configCallback,
6504
- dynamic
6505
- };
6506
- WireMetaMap.set(descriptor, def);
6807
+ // Our detection logic relies on some modern browser features. We can just skip reporting the data
6808
+ // for unsupported browsers
6809
+ function supportsCssEscape() {
6810
+ return typeof CSS !== 'undefined' && isFunction$1(CSS.escape);
6507
6811
  }
6508
- function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
6509
- // support for callable adapters
6510
- if (adapter.adapter) {
6511
- adapter = adapter.adapter;
6512
- }
6513
- const def = {
6514
- adapter,
6515
- configCallback,
6516
- dynamic
6517
- };
6518
- WireMetaMap.set(descriptor, def);
6812
+ // If this page is not using synthetic shadow, then we don't need to install detection. Note
6813
+ // that we are assuming synthetic shadow is loaded before LWC.
6814
+ function isSyntheticShadowLoaded() {
6815
+ // We should probably be calling `renderer.isSyntheticShadowDefined`, but 1) we don't have access to the renderer,
6816
+ // and 2) this code needs to run in @lwc/engine-core, so it can access `logWarn()` and `report()`.
6817
+ return hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
6519
6818
  }
6520
- function installWireAdapters(vm) {
6521
- const {
6522
- context,
6523
- def: {
6524
- wire
6525
- }
6526
- } = vm;
6527
- if (process.env.NODE_ENV !== 'production') {
6528
- vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
6529
- }
6530
- const wiredConnecting = context.wiredConnecting = [];
6531
- const wiredDisconnecting = context.wiredDisconnecting = [];
6532
- for (const fieldNameOrMethod in wire) {
6533
- const descriptor = wire[fieldNameOrMethod];
6534
- const wireDef = WireMetaMap.get(descriptor);
6819
+ // Detecting cross-root ARIA in synthetic shadow only makes sense for the browser
6820
+ if (supportsCssEscape() && isSyntheticShadowLoaded()) {
6821
+ // Always run detection in dev mode, so we can at least print to the console
6535
6822
  if (process.env.NODE_ENV !== 'production') {
6536
- assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
6823
+ enableDetection();
6537
6824
  }
6538
- if (!isUndefined$1(wireDef)) {
6539
- const {
6540
- connector,
6541
- computeConfigAndUpdate,
6542
- resetConfigWatcher
6543
- } = createConnector(vm, fieldNameOrMethod, wireDef);
6544
- const hasDynamicParams = wireDef.dynamic.length > 0;
6545
- ArrayPush$1.call(wiredConnecting, () => {
6546
- connector.connect();
6547
- if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
6548
- if (hasDynamicParams) {
6549
- Promise.resolve().then(computeConfigAndUpdate);
6550
- return;
6551
- }
6552
- }
6553
- computeConfigAndUpdate();
6554
- });
6555
- ArrayPush$1.call(wiredDisconnecting, () => {
6556
- connector.disconnect();
6557
- resetConfigWatcher();
6558
- });
6559
- }
6560
- }
6561
- }
6562
- function connectWireAdapters(vm) {
6563
- const {
6564
- wiredConnecting
6565
- } = vm.context;
6566
- for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
6567
- wiredConnecting[i]();
6568
- }
6569
- }
6570
- function disconnectWireAdapters(vm) {
6571
- const {
6572
- wiredDisconnecting
6573
- } = vm.context;
6574
- runWithBoundaryProtection(vm, vm, noop, () => {
6575
- // job
6576
- for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
6577
- wiredDisconnecting[i]();
6825
+ else {
6826
+ // In prod mode, only enable detection if reporting is enabled
6827
+ onReportingEnabled(enableDetection);
6578
6828
  }
6579
- }, noop);
6580
6829
  }
6581
6830
 
6582
6831
  /*
@@ -7248,7 +7497,7 @@
7248
7497
  }
7249
7498
  return ctor;
7250
7499
  }
7251
- /* version: 2.34.0 */
7500
+ /* version: 2.35.0 */
7252
7501
 
7253
7502
  /*
7254
7503
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8223,7 +8472,7 @@
8223
8472
  function isNull(obj) {
8224
8473
  return obj === null;
8225
8474
  }
8226
- /** version: 2.34.0 */
8475
+ /** version: 2.35.0 */
8227
8476
 
8228
8477
  /*
8229
8478
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8784,10 +9033,11 @@
8784
9033
  });
8785
9034
  freeze(LightningElement);
8786
9035
  seal(LightningElement.prototype);
8787
- /* version: 2.34.0 */
9036
+ /* version: 2.35.0 */
8788
9037
 
8789
9038
  exports.LightningElement = LightningElement;
8790
9039
  exports.__unstable__ProfilerControl = profilerControl;
9040
+ exports.__unstable__ReportingControl = reportingControl;
8791
9041
  exports.api = api$1;
8792
9042
  exports.buildCustomElementConstructor = deprecatedBuildCustomElementConstructor;
8793
9043
  exports.createContextProvider = createContextProvider;