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