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