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
  }
@@ -182,6 +182,19 @@ var LWC = (function (exports) {
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 @@ var LWC = (function (exports) {
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';
@@ -336,7 +351,7 @@ var LWC = (function (exports) {
336
351
  CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
337
352
  return propertyName;
338
353
  }
339
- /** version: 2.34.0 */
354
+ /** version: 2.35.0 */
340
355
 
341
356
  /**
342
357
  * Copyright (C) 2018 salesforce.com, inc.
@@ -403,7 +418,7 @@ var LWC = (function (exports) {
403
418
  */
404
419
  function setFeatureFlagForTest(name, value) {
405
420
  }
406
- /** version: 2.34.0 */
421
+ /** version: 2.35.0 */
407
422
 
408
423
  /**
409
424
  * Copyright (C) 2018 salesforce.com, inc.
@@ -467,7 +482,7 @@ var LWC = (function (exports) {
467
482
  }
468
483
  }
469
484
  }
470
- /** version: 2.34.0 */
485
+ /** version: 2.35.0 */
471
486
 
472
487
  /*
473
488
  * Copyright (c) 2018, salesforce.com, inc.
@@ -487,81 +502,148 @@ var LWC = (function (exports) {
487
502
  * SPDX-License-Identifier: MIT
488
503
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
489
504
  */
490
- let nextTickCallbackQueue = [];
491
- const SPACE_CHAR = 32;
492
- const EmptyObject = seal(create(null));
493
- const EmptyArray = seal([]);
494
- function flushCallbackQueue() {
495
- const callbacks = nextTickCallbackQueue;
496
- nextTickCallbackQueue = []; // reset to a new queue
497
- for (let i = 0, len = callbacks.length; i < len; i += 1) {
498
- callbacks[i]();
505
+ /** Callbacks to invoke when reporting is enabled **/
506
+ const onReportingEnabledCallbacks = [];
507
+ /** The currently assigned reporting dispatcher. */
508
+ let currentDispatcher$1 = noop;
509
+ /**
510
+ * Whether reporting is enabled.
511
+ *
512
+ * Note that this may seem redundant, given you can just check if the currentDispatcher is undefined,
513
+ * but it turns out that Terser only strips out unused code if we use this explicit boolean.
514
+ */
515
+ let enabled$1 = false;
516
+ const reportingControl = {
517
+ /**
518
+ * Attach a new reporting control (aka dispatcher).
519
+ *
520
+ * @param dispatcher - reporting control
521
+ */
522
+ attachDispatcher(dispatcher) {
523
+ enabled$1 = true;
524
+ currentDispatcher$1 = dispatcher;
525
+ for (const callback of onReportingEnabledCallbacks) {
526
+ try {
527
+ callback();
528
+ }
529
+ catch (err) {
530
+ // This should never happen. But if it does, we don't want one callback to cause another to fail
531
+ // eslint-disable-next-line no-console
532
+ console.error('Could not invoke callback', err);
533
+ }
534
+ }
535
+ onReportingEnabledCallbacks.length = 0; // clear the array
536
+ },
537
+ /**
538
+ * Detach the current reporting control (aka dispatcher).
539
+ */
540
+ detachDispatcher() {
541
+ enabled$1 = false;
542
+ currentDispatcher$1 = noop;
543
+ },
544
+ };
545
+ /**
546
+ * Call a callback when reporting is enabled, or immediately if reporting is already enabled.
547
+ * Will only ever be called once.
548
+ * @param callback
549
+ */
550
+ function onReportingEnabled(callback) {
551
+ if (enabled$1) {
552
+ // call immediately
553
+ callback();
554
+ }
555
+ else {
556
+ // call later
557
+ onReportingEnabledCallbacks.push(callback);
499
558
  }
500
559
  }
501
- function addCallbackToNextTick(callback) {
502
- if (nextTickCallbackQueue.length === 0) {
503
- Promise.resolve().then(flushCallbackQueue);
560
+ /**
561
+ * Report to the current dispatcher, if there is one.
562
+ * @param reportingEventId
563
+ * @param vm
564
+ */
565
+ function report(reportingEventId, vm) {
566
+ if (enabled$1) {
567
+ currentDispatcher$1(reportingEventId, vm.tagName, vm.idx);
504
568
  }
505
- ArrayPush$1.call(nextTickCallbackQueue, callback);
506
569
  }
507
- function guid() {
508
- function s4() {
509
- return Math.floor((1 + Math.random()) * 0x10000)
510
- .toString(16)
511
- .substring(1);
570
+
571
+ /*
572
+ * Copyright (c) 2018, salesforce.com, inc.
573
+ * All rights reserved.
574
+ * SPDX-License-Identifier: MIT
575
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
576
+ */
577
+ function getComponentTag(vm) {
578
+ return `<${StringToLowerCase.call(vm.tagName)}>`;
579
+ }
580
+ // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
581
+ function getComponentStack(vm) {
582
+ const stack = [];
583
+ let prefix = '';
584
+ while (!isNull(vm.owner)) {
585
+ ArrayPush$1.call(stack, prefix + getComponentTag(vm));
586
+ vm = vm.owner;
587
+ prefix += '\t';
512
588
  }
513
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
589
+ return ArrayJoin.call(stack, '\n');
514
590
  }
515
- // Borrowed from Vue template compiler.
516
- // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
517
- const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
518
- const PROPERTY_DELIMITER = /:(.+)/;
519
- function parseStyleText(cssText) {
520
- const styleMap = {};
521
- const declarations = cssText.split(DECLARATION_DELIMITER);
522
- for (const declaration of declarations) {
523
- if (declaration) {
524
- const [prop, value] = declaration.split(PROPERTY_DELIMITER);
525
- if (prop !== undefined && value !== undefined) {
526
- styleMap[prop.trim()] = value.trim();
527
- }
528
- }
591
+ function getErrorComponentStack(vm) {
592
+ const wcStack = [];
593
+ let currentVm = vm;
594
+ while (!isNull(currentVm)) {
595
+ ArrayPush$1.call(wcStack, getComponentTag(currentVm));
596
+ currentVm = currentVm.owner;
529
597
  }
530
- return styleMap;
598
+ return wcStack.reverse().join('\n\t');
531
599
  }
532
- // Make a shallow copy of an object but omit the given key
533
- function cloneAndOmitKey(object, keyToOmit) {
534
- const result = {};
535
- for (const key of Object.keys(object)) {
536
- if (key !== keyToOmit) {
537
- result[key] = object[key];
538
- }
600
+
601
+ /*
602
+ * Copyright (c) 2018, salesforce.com, inc.
603
+ * All rights reserved.
604
+ * SPDX-License-Identifier: MIT
605
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
606
+ */
607
+ function addErrorComponentStack(vm, error) {
608
+ if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
609
+ const wcStack = getErrorComponentStack(vm);
610
+ defineProperty(error, 'wcStack', {
611
+ get() {
612
+ return wcStack;
613
+ },
614
+ });
539
615
  }
540
- return result;
541
616
  }
542
- function flattenStylesheets(stylesheets) {
543
- const list = [];
544
- for (const stylesheet of stylesheets) {
545
- if (!Array.isArray(stylesheet)) {
546
- list.push(stylesheet);
547
- }
548
- else {
549
- list.push(...flattenStylesheets(stylesheet));
617
+
618
+ /*
619
+ * Copyright (c) 2018, salesforce.com, inc.
620
+ * All rights reserved.
621
+ * SPDX-License-Identifier: MIT
622
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
623
+ */
624
+ const alreadyLoggedMessages = new Set();
625
+ function log(method, message, vm, once) {
626
+ let msg = `[LWC ${method}]: ${message}`;
627
+ if (!isUndefined$1(vm)) {
628
+ msg = `${msg}\n${getComponentStack(vm)}`;
629
+ }
630
+ if (once) {
631
+ if (alreadyLoggedMessages.has(msg)) {
632
+ return;
550
633
  }
634
+ alreadyLoggedMessages.add(msg);
551
635
  }
552
- return list;
553
- }
554
- // Set a ref (lwc:ref) on a VM, from a template API
555
- function setRefVNode(vm, ref, vnode) {
556
- // If this method is called, then vm.refVNodes is set as the template has refs.
557
- // If not, then something went wrong and we threw an error above.
558
- const refVNodes = vm.refVNodes;
559
- // In cases of conflict (two elements with the same ref), prefer, the last one,
560
- // in depth-first traversal order.
561
- if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
562
- refVNodes[ref] = vnode;
636
+ try {
637
+ throw new Error(msg);
638
+ }
639
+ catch (e) {
640
+ /* eslint-disable-next-line no-console */
641
+ console[method](e);
563
642
  }
564
643
  }
644
+ function logError(message, vm) {
645
+ log('error', message, vm, false);
646
+ }
565
647
 
566
648
  /*
567
649
  * Copyright (c) 2019, salesforce.com, inc.
@@ -683,82 +765,94 @@ var LWC = (function (exports) {
683
765
  * SPDX-License-Identifier: MIT
684
766
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
685
767
  */
686
- function getComponentTag(vm) {
687
- return `<${StringToLowerCase.call(vm.tagName)}>`;
768
+ let nextTickCallbackQueue = [];
769
+ const SPACE_CHAR = 32;
770
+ const EmptyObject = seal(create(null));
771
+ const EmptyArray = seal([]);
772
+ function flushCallbackQueue() {
773
+ const callbacks = nextTickCallbackQueue;
774
+ nextTickCallbackQueue = []; // reset to a new queue
775
+ for (let i = 0, len = callbacks.length; i < len; i += 1) {
776
+ callbacks[i]();
777
+ }
688
778
  }
689
- // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
690
- function getComponentStack(vm) {
691
- const stack = [];
692
- let prefix = '';
693
- while (!isNull(vm.owner)) {
694
- ArrayPush$1.call(stack, prefix + getComponentTag(vm));
695
- vm = vm.owner;
696
- prefix += '\t';
779
+ function addCallbackToNextTick(callback) {
780
+ if (nextTickCallbackQueue.length === 0) {
781
+ Promise.resolve().then(flushCallbackQueue);
697
782
  }
698
- return ArrayJoin.call(stack, '\n');
783
+ ArrayPush$1.call(nextTickCallbackQueue, callback);
699
784
  }
700
- function getErrorComponentStack(vm) {
701
- const wcStack = [];
702
- let currentVm = vm;
703
- while (!isNull(currentVm)) {
704
- ArrayPush$1.call(wcStack, getComponentTag(currentVm));
705
- currentVm = currentVm.owner;
785
+ function guid() {
786
+ function s4() {
787
+ return Math.floor((1 + Math.random()) * 0x10000)
788
+ .toString(16)
789
+ .substring(1);
790
+ }
791
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
792
+ }
793
+ // Borrowed from Vue template compiler.
794
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
795
+ const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
796
+ const PROPERTY_DELIMITER = /:(.+)/;
797
+ function parseStyleText(cssText) {
798
+ const styleMap = {};
799
+ const declarations = cssText.split(DECLARATION_DELIMITER);
800
+ for (const declaration of declarations) {
801
+ if (declaration) {
802
+ const [prop, value] = declaration.split(PROPERTY_DELIMITER);
803
+ if (prop !== undefined && value !== undefined) {
804
+ styleMap[prop.trim()] = value.trim();
805
+ }
806
+ }
807
+ }
808
+ return styleMap;
809
+ }
810
+ // Make a shallow copy of an object but omit the given key
811
+ function cloneAndOmitKey(object, keyToOmit) {
812
+ const result = {};
813
+ for (const key of Object.keys(object)) {
814
+ if (key !== keyToOmit) {
815
+ result[key] = object[key];
816
+ }
817
+ }
818
+ return result;
819
+ }
820
+ function flattenStylesheets(stylesheets) {
821
+ const list = [];
822
+ for (const stylesheet of stylesheets) {
823
+ if (!Array.isArray(stylesheet)) {
824
+ list.push(stylesheet);
825
+ }
826
+ else {
827
+ list.push(...flattenStylesheets(stylesheet));
828
+ }
829
+ }
830
+ return list;
831
+ }
832
+ // Set a ref (lwc:ref) on a VM, from a template API
833
+ function setRefVNode(vm, ref, vnode) {
834
+ // If this method is called, then vm.refVNodes is set as the template has refs.
835
+ // If not, then something went wrong and we threw an error above.
836
+ const refVNodes = vm.refVNodes;
837
+ // In cases of conflict (two elements with the same ref), prefer, the last one,
838
+ // in depth-first traversal order.
839
+ if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
840
+ refVNodes[ref] = vnode;
706
841
  }
707
- return wcStack.reverse().join('\n\t');
708
842
  }
709
843
 
710
844
  /*
711
- * Copyright (c) 2018, salesforce.com, inc.
845
+ * Copyright (c) 2020, salesforce.com, inc.
712
846
  * All rights reserved.
713
847
  * SPDX-License-Identifier: MIT
714
848
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
715
849
  */
716
- function addErrorComponentStack(vm, error) {
717
- if (!isFrozen(error) && isUndefined$1(error.wcStack)) {
718
- const wcStack = getErrorComponentStack(vm);
719
- defineProperty(error, 'wcStack', {
720
- get() {
721
- return wcStack;
722
- },
723
- });
724
- }
725
- }
726
-
727
- /*
728
- * Copyright (c) 2018, salesforce.com, inc.
729
- * All rights reserved.
730
- * SPDX-License-Identifier: MIT
731
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
732
- */
733
- function log(method, message, vm) {
734
- let msg = `[LWC ${method}]: ${message}`;
735
- if (!isUndefined$1(vm)) {
736
- msg = `${msg}\n${getComponentStack(vm)}`;
737
- }
738
- try {
739
- throw new Error(msg);
740
- }
741
- catch (e) {
742
- /* eslint-disable-next-line no-console */
743
- console[method](e);
744
- }
745
- }
746
- function logError(message, vm) {
747
- log('error', message, vm);
748
- }
749
-
750
- /*
751
- * Copyright (c) 2020, salesforce.com, inc.
752
- * All rights reserved.
753
- * SPDX-License-Identifier: MIT
754
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
755
- */
756
- function resolveCircularModuleDependency(fn) {
757
- const module = fn();
758
- return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
759
- }
760
- function isCircularModuleDependency(obj) {
761
- return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
850
+ function resolveCircularModuleDependency(fn) {
851
+ const module = fn();
852
+ return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
853
+ }
854
+ function isCircularModuleDependency(obj) {
855
+ return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
762
856
  }
763
857
 
764
858
  /*
@@ -790,101 +884,6 @@ var LWC = (function (exports) {
790
884
  'tabIndex',
791
885
  'title',
792
886
  ];
793
- function offsetPropertyErrorMessage(name) {
794
- return `Using the \`${name}\` property is an anti-pattern because it rounds the value to an integer. Instead, use the \`getBoundingClientRect\` method to obtain fractional values for the size of an element and its position relative to the viewport.`;
795
- }
796
- // Global HTML Attributes & Properties
797
- // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
798
- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
799
- //
800
- // If you update this list, check for test files that recapitulate the same list. Searching the codebase
801
- // for e.g. "dropzone" should suffice.
802
- assign(create(null), {
803
- accessKey: {
804
- attribute: 'accesskey',
805
- },
806
- accessKeyLabel: {
807
- readOnly: true,
808
- },
809
- className: {
810
- attribute: 'class',
811
- error: 'Using the `className` property is an anti-pattern because of slow runtime behavior and potential conflicts with classes provided by the owner element. Use the `classList` API instead.',
812
- },
813
- contentEditable: {
814
- attribute: 'contenteditable',
815
- },
816
- dataset: {
817
- readOnly: true,
818
- error: "Using the `dataset` property is an anti-pattern because it can't be statically analyzed. Expose each property individually using the `@api` decorator instead.",
819
- },
820
- dir: {
821
- attribute: 'dir',
822
- },
823
- draggable: {
824
- attribute: 'draggable',
825
- },
826
- dropzone: {
827
- attribute: 'dropzone',
828
- readOnly: true,
829
- },
830
- hidden: {
831
- attribute: 'hidden',
832
- },
833
- id: {
834
- attribute: 'id',
835
- },
836
- inputMode: {
837
- attribute: 'inputmode',
838
- },
839
- lang: {
840
- attribute: 'lang',
841
- },
842
- slot: {
843
- attribute: 'slot',
844
- error: 'Using the `slot` property is an anti-pattern.',
845
- },
846
- spellcheck: {
847
- attribute: 'spellcheck',
848
- },
849
- style: {
850
- attribute: 'style',
851
- },
852
- tabIndex: {
853
- attribute: 'tabindex',
854
- },
855
- title: {
856
- attribute: 'title',
857
- },
858
- translate: {
859
- attribute: 'translate',
860
- },
861
- // additional "global attributes" that are not present in the link above.
862
- isContentEditable: {
863
- readOnly: true,
864
- },
865
- offsetHeight: {
866
- readOnly: true,
867
- error: offsetPropertyErrorMessage('offsetHeight'),
868
- },
869
- offsetLeft: {
870
- readOnly: true,
871
- error: offsetPropertyErrorMessage('offsetLeft'),
872
- },
873
- offsetParent: {
874
- readOnly: true,
875
- },
876
- offsetTop: {
877
- readOnly: true,
878
- error: offsetPropertyErrorMessage('offsetTop'),
879
- },
880
- offsetWidth: {
881
- readOnly: true,
882
- error: offsetPropertyErrorMessage('offsetWidth'),
883
- },
884
- role: {
885
- attribute: 'role',
886
- },
887
- });
888
887
  let controlledElement = null;
889
888
  let controlledAttributeName;
890
889
  function isAttributeLocked(elm, attrName) {
@@ -1818,114 +1817,378 @@ var LWC = (function (exports) {
1818
1817
  * SPDX-License-Identifier: MIT
1819
1818
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1820
1819
  */
1821
- function api$1() {
1822
- throw new Error();
1820
+ const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
1821
+ const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
1822
+ const WireMetaMap = new Map();
1823
+ class WireContextRegistrationEvent extends CustomEvent {
1824
+ constructor(adapterToken, {
1825
+ setNewContext,
1826
+ setDisconnectedCallback
1827
+ }) {
1828
+ super(adapterToken, {
1829
+ bubbles: true,
1830
+ composed: true
1831
+ });
1832
+ defineProperties(this, {
1833
+ setNewContext: {
1834
+ value: setNewContext
1835
+ },
1836
+ setDisconnectedCallback: {
1837
+ value: setDisconnectedCallback
1838
+ }
1839
+ });
1840
+ }
1823
1841
  }
1824
- function createPublicPropertyDescriptor(key) {
1825
- return {
1826
- get() {
1827
- const vm = getAssociatedVM(this);
1828
- if (isBeingConstructed(vm)) {
1829
- return;
1830
- }
1831
- componentValueObserved(vm, key);
1832
- return vm.cmpProps[key];
1833
- },
1834
- set(newValue) {
1835
- const vm = getAssociatedVM(this);
1836
- vm.cmpProps[key] = newValue;
1837
- componentValueMutated(vm, key);
1838
- },
1839
- enumerable: true,
1840
- configurable: true,
1841
- };
1842
+ function createFieldDataCallback(vm, name) {
1843
+ return value => {
1844
+ updateComponentValue(vm, name, value);
1845
+ };
1842
1846
  }
1843
- function createPublicAccessorDescriptor(key, descriptor) {
1844
- const { get, set, enumerable, configurable } = descriptor;
1845
- if (!isFunction$1(get)) {
1846
- throw new Error();
1847
- }
1848
- return {
1849
- get() {
1850
- return get.call(this);
1851
- },
1852
- set(newValue) {
1853
- getAssociatedVM(this);
1854
- if (set) {
1855
- set.call(this, newValue);
1856
- }
1857
- },
1858
- enumerable,
1859
- configurable,
1860
- };
1847
+ function createMethodDataCallback(vm, method) {
1848
+ return value => {
1849
+ // dispatching new value into the wired method
1850
+ runWithBoundaryProtection(vm, vm.owner, noop, () => {
1851
+ // job
1852
+ method.call(vm.component, value);
1853
+ }, noop);
1854
+ };
1861
1855
  }
1862
-
1863
- /*
1864
- * Copyright (c) 2018, salesforce.com, inc.
1865
- * All rights reserved.
1866
- * SPDX-License-Identifier: MIT
1867
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1868
- */
1869
- function track(target) {
1870
- if (arguments.length === 1) {
1871
- return getReactiveProxy(target);
1856
+ function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
1857
+ let hasPendingConfig = false;
1858
+ // creating the reactive observer for reactive params when needed
1859
+ const ro = createReactiveObserver(() => {
1860
+ if (hasPendingConfig === false) {
1861
+ hasPendingConfig = true;
1862
+ // collect new config in the micro-task
1863
+ Promise.resolve().then(() => {
1864
+ hasPendingConfig = false;
1865
+ // resetting current reactive params
1866
+ ro.reset();
1867
+ // dispatching a new config due to a change in the configuration
1868
+ computeConfigAndUpdate();
1869
+ });
1872
1870
  }
1873
- throw new Error();
1874
- }
1875
- function internalTrackDecorator(key) {
1876
- return {
1877
- get() {
1878
- const vm = getAssociatedVM(this);
1879
- componentValueObserved(vm, key);
1880
- return vm.cmpFields[key];
1881
- },
1882
- set(newValue) {
1883
- const vm = getAssociatedVM(this);
1884
- const reactiveOrAnyValue = getReactiveProxy(newValue);
1885
- updateComponentValue(vm, key, reactiveOrAnyValue);
1886
- },
1887
- enumerable: true,
1888
- configurable: true,
1889
- };
1871
+ });
1872
+ const computeConfigAndUpdate = () => {
1873
+ let config;
1874
+ ro.observe(() => config = configCallback(component));
1875
+ // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
1876
+ // TODO: dev-mode validation of config based on the adapter.configSchema
1877
+ // @ts-ignore it is assigned in the observe() callback
1878
+ callbackWhenConfigIsReady(config);
1879
+ };
1880
+ return {
1881
+ computeConfigAndUpdate,
1882
+ ro
1883
+ };
1890
1884
  }
1885
+ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
1886
+ const {
1887
+ adapter
1888
+ } = wireDef;
1889
+ const adapterContextToken = getAdapterToken(adapter);
1890
+ if (isUndefined$1(adapterContextToken)) {
1891
+ return; // no provider found, nothing to be done
1892
+ }
1891
1893
 
1892
- /*
1893
- * Copyright (c) 2018, salesforce.com, inc.
1894
- * All rights reserved.
1895
- * SPDX-License-Identifier: MIT
1896
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1897
- */
1898
- /**
1899
- * @wire decorator to wire fields and methods to a wire adapter in
1900
- * LWC Components. This function implements the internals of this
1901
- * decorator.
1902
- */
1903
- function wire(_adapter, _config) {
1904
- throw new Error();
1905
- }
1906
- function internalWireFieldDecorator(key) {
1907
- return {
1908
- get() {
1909
- const vm = getAssociatedVM(this);
1910
- componentValueObserved(vm, key);
1911
- return vm.cmpFields[key];
1912
- },
1913
- set(value) {
1914
- const vm = getAssociatedVM(this);
1915
- /**
1916
- * Reactivity for wired fields is provided in wiring.
1917
- * We intentionally add reactivity here since this is just
1918
- * letting the author to do the wrong thing, but it will keep our
1919
- * system to be backward compatible.
1920
- */
1921
- updateComponentValue(vm, key, value);
1922
- },
1923
- enumerable: true,
1924
- configurable: true,
1925
- };
1894
+ const {
1895
+ elm,
1896
+ context: {
1897
+ wiredConnecting,
1898
+ wiredDisconnecting
1899
+ },
1900
+ renderer: {
1901
+ dispatchEvent
1902
+ }
1903
+ } = vm;
1904
+ // waiting for the component to be connected to formally request the context via the token
1905
+ ArrayPush$1.call(wiredConnecting, () => {
1906
+ // This event is responsible for connecting the host element with another
1907
+ // element in the composed path that is providing contextual data. The provider
1908
+ // must be listening for a special dom event with the name corresponding to the value of
1909
+ // `adapterContextToken`, which will remain secret and internal to this file only to
1910
+ // guarantee that the linkage can be forged.
1911
+ const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
1912
+ setNewContext(newContext) {
1913
+ // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
1914
+ // TODO: dev-mode validation of config based on the adapter.contextSchema
1915
+ callbackWhenContextIsReady(newContext);
1916
+ },
1917
+ setDisconnectedCallback(disconnectCallback) {
1918
+ // adds this callback into the disconnect bucket so it gets disconnected from parent
1919
+ // the the element hosting the wire is disconnected
1920
+ ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
1921
+ }
1922
+ });
1923
+ dispatchEvent(elm, contextRegistrationEvent);
1924
+ });
1926
1925
  }
1927
- /**
1928
- * INTERNAL: This function can only be invoked by compiled code. The compiler
1926
+ function createConnector(vm, name, wireDef) {
1927
+ const {
1928
+ method,
1929
+ adapter,
1930
+ configCallback,
1931
+ dynamic
1932
+ } = wireDef;
1933
+ let debugInfo;
1934
+ const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
1935
+ const dataCallback = value => {
1936
+ fieldOrMethodCallback(value);
1937
+ };
1938
+ let context;
1939
+ let connector;
1940
+ // Workaround to pass the component element associated to this wire adapter instance.
1941
+ defineProperty(dataCallback, DeprecatedWiredElementHost, {
1942
+ value: vm.elm
1943
+ });
1944
+ defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
1945
+ value: dynamic
1946
+ });
1947
+ runWithBoundaryProtection(vm, vm, noop, () => {
1948
+ // job
1949
+ connector = new adapter(dataCallback);
1950
+ }, noop);
1951
+ const updateConnectorConfig = config => {
1952
+ // every time the config is recomputed due to tracking,
1953
+ // this callback will be invoked with the new computed config
1954
+ runWithBoundaryProtection(vm, vm, noop, () => {
1955
+ // job
1956
+ if ("production" !== 'production') ;
1957
+ connector.update(config, context);
1958
+ }, noop);
1959
+ };
1960
+ // Computes the current wire config and calls the update method on the wire adapter.
1961
+ // If it has params, we will need to observe changes in the next tick.
1962
+ const {
1963
+ computeConfigAndUpdate,
1964
+ ro
1965
+ } = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
1966
+ // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
1967
+ if (!isUndefined$1(adapter.contextSchema)) {
1968
+ createContextWatcher(vm, wireDef, newContext => {
1969
+ // every time the context is pushed into this component,
1970
+ // this callback will be invoked with the new computed context
1971
+ if (context !== newContext) {
1972
+ context = newContext;
1973
+ // Note: when new context arrives, the config will be recomputed and pushed along side the new
1974
+ // context, this is to preserve the identity characteristics, config should not have identity
1975
+ // (ever), while context can have identity
1976
+ if (vm.state === 1 /* VMState.connected */) {
1977
+ computeConfigAndUpdate();
1978
+ }
1979
+ }
1980
+ });
1981
+ }
1982
+ return {
1983
+ // @ts-ignore the boundary protection executes sync, connector is always defined
1984
+ connector,
1985
+ computeConfigAndUpdate,
1986
+ resetConfigWatcher: () => ro.reset()
1987
+ };
1988
+ }
1989
+ const AdapterToTokenMap = new Map();
1990
+ function getAdapterToken(adapter) {
1991
+ return AdapterToTokenMap.get(adapter);
1992
+ }
1993
+ function setAdapterToken(adapter, token) {
1994
+ AdapterToTokenMap.set(adapter, token);
1995
+ }
1996
+ function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
1997
+ // support for callable adapters
1998
+ if (adapter.adapter) {
1999
+ adapter = adapter.adapter;
2000
+ }
2001
+ const method = descriptor.value;
2002
+ const def = {
2003
+ adapter,
2004
+ method,
2005
+ configCallback,
2006
+ dynamic
2007
+ };
2008
+ WireMetaMap.set(descriptor, def);
2009
+ }
2010
+ function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
2011
+ // support for callable adapters
2012
+ if (adapter.adapter) {
2013
+ adapter = adapter.adapter;
2014
+ }
2015
+ const def = {
2016
+ adapter,
2017
+ configCallback,
2018
+ dynamic
2019
+ };
2020
+ WireMetaMap.set(descriptor, def);
2021
+ }
2022
+ function installWireAdapters(vm) {
2023
+ const {
2024
+ context,
2025
+ def: {
2026
+ wire
2027
+ }
2028
+ } = vm;
2029
+ const wiredConnecting = context.wiredConnecting = [];
2030
+ const wiredDisconnecting = context.wiredDisconnecting = [];
2031
+ for (const fieldNameOrMethod in wire) {
2032
+ const descriptor = wire[fieldNameOrMethod];
2033
+ const wireDef = WireMetaMap.get(descriptor);
2034
+ if (!isUndefined$1(wireDef)) {
2035
+ const {
2036
+ connector,
2037
+ computeConfigAndUpdate,
2038
+ resetConfigWatcher
2039
+ } = createConnector(vm, fieldNameOrMethod, wireDef);
2040
+ const hasDynamicParams = wireDef.dynamic.length > 0;
2041
+ ArrayPush$1.call(wiredConnecting, () => {
2042
+ connector.connect();
2043
+ if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
2044
+ if (hasDynamicParams) {
2045
+ Promise.resolve().then(computeConfigAndUpdate);
2046
+ return;
2047
+ }
2048
+ }
2049
+ computeConfigAndUpdate();
2050
+ });
2051
+ ArrayPush$1.call(wiredDisconnecting, () => {
2052
+ connector.disconnect();
2053
+ resetConfigWatcher();
2054
+ });
2055
+ }
2056
+ }
2057
+ }
2058
+ function connectWireAdapters(vm) {
2059
+ const {
2060
+ wiredConnecting
2061
+ } = vm.context;
2062
+ for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
2063
+ wiredConnecting[i]();
2064
+ }
2065
+ }
2066
+ function disconnectWireAdapters(vm) {
2067
+ const {
2068
+ wiredDisconnecting
2069
+ } = vm.context;
2070
+ runWithBoundaryProtection(vm, vm, noop, () => {
2071
+ // job
2072
+ for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
2073
+ wiredDisconnecting[i]();
2074
+ }
2075
+ }, noop);
2076
+ }
2077
+
2078
+ /*
2079
+ * Copyright (c) 2018, salesforce.com, inc.
2080
+ * All rights reserved.
2081
+ * SPDX-License-Identifier: MIT
2082
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2083
+ */
2084
+ function api$1() {
2085
+ throw new Error();
2086
+ }
2087
+ function createPublicPropertyDescriptor(key) {
2088
+ return {
2089
+ get() {
2090
+ const vm = getAssociatedVM(this);
2091
+ if (isBeingConstructed(vm)) {
2092
+ return;
2093
+ }
2094
+ componentValueObserved(vm, key);
2095
+ return vm.cmpProps[key];
2096
+ },
2097
+ set(newValue) {
2098
+ const vm = getAssociatedVM(this);
2099
+ vm.cmpProps[key] = newValue;
2100
+ componentValueMutated(vm, key);
2101
+ },
2102
+ enumerable: true,
2103
+ configurable: true,
2104
+ };
2105
+ }
2106
+ function createPublicAccessorDescriptor(key, descriptor) {
2107
+ const { get, set, enumerable, configurable } = descriptor;
2108
+ if (!isFunction$1(get)) {
2109
+ throw new Error();
2110
+ }
2111
+ return {
2112
+ get() {
2113
+ return get.call(this);
2114
+ },
2115
+ set(newValue) {
2116
+ getAssociatedVM(this);
2117
+ if (set) {
2118
+ set.call(this, newValue);
2119
+ }
2120
+ },
2121
+ enumerable,
2122
+ configurable,
2123
+ };
2124
+ }
2125
+
2126
+ /*
2127
+ * Copyright (c) 2018, salesforce.com, inc.
2128
+ * All rights reserved.
2129
+ * SPDX-License-Identifier: MIT
2130
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2131
+ */
2132
+ function track(target) {
2133
+ if (arguments.length === 1) {
2134
+ return getReactiveProxy(target);
2135
+ }
2136
+ throw new Error();
2137
+ }
2138
+ function internalTrackDecorator(key) {
2139
+ return {
2140
+ get() {
2141
+ const vm = getAssociatedVM(this);
2142
+ componentValueObserved(vm, key);
2143
+ return vm.cmpFields[key];
2144
+ },
2145
+ set(newValue) {
2146
+ const vm = getAssociatedVM(this);
2147
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
2148
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2149
+ },
2150
+ enumerable: true,
2151
+ configurable: true,
2152
+ };
2153
+ }
2154
+
2155
+ /*
2156
+ * Copyright (c) 2018, salesforce.com, inc.
2157
+ * All rights reserved.
2158
+ * SPDX-License-Identifier: MIT
2159
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2160
+ */
2161
+ /**
2162
+ * @wire decorator to wire fields and methods to a wire adapter in
2163
+ * LWC Components. This function implements the internals of this
2164
+ * decorator.
2165
+ */
2166
+ function wire(_adapter, _config) {
2167
+ throw new Error();
2168
+ }
2169
+ function internalWireFieldDecorator(key) {
2170
+ return {
2171
+ get() {
2172
+ const vm = getAssociatedVM(this);
2173
+ componentValueObserved(vm, key);
2174
+ return vm.cmpFields[key];
2175
+ },
2176
+ set(value) {
2177
+ const vm = getAssociatedVM(this);
2178
+ /**
2179
+ * Reactivity for wired fields is provided in wiring.
2180
+ * We intentionally add reactivity here since this is just
2181
+ * letting the author to do the wrong thing, but it will keep our
2182
+ * system to be backward compatible.
2183
+ */
2184
+ updateComponentValue(vm, key, value);
2185
+ },
2186
+ enumerable: true,
2187
+ configurable: true,
2188
+ };
2189
+ }
2190
+ /**
2191
+ * INTERNAL: This function can only be invoked by compiled code. The compiler
1929
2192
  * will prevent this function from being imported by user-land code.
1930
2193
  */
1931
2194
  function registerDecorators(Ctor, meta) {
@@ -4812,338 +5075,210 @@ var LWC = (function (exports) {
4812
5075
  break;
4813
5076
  }
4814
5077
  }
4815
- }
4816
- }
4817
- }
4818
- // This is a super optimized mechanism to remove the content of the root node (shadow root
4819
- // for shadow DOM components and the root element itself for light DOM) without having to go
4820
- // into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
4821
- // children VNodes might not be representing the current state of the DOM.
4822
- function resetComponentRoot(vm) {
4823
- const {
4824
- children,
4825
- renderRoot,
4826
- renderer: {
4827
- remove
4828
- }
4829
- } = vm;
4830
- for (let i = 0, len = children.length; i < len; i++) {
4831
- const child = children[i];
4832
- if (!isNull(child) && !isUndefined$1(child.elm)) {
4833
- remove(child.elm, renderRoot);
4834
- }
4835
- }
4836
- vm.children = EmptyArray;
4837
- runChildNodesDisconnectedCallback(vm);
4838
- vm.velements = EmptyArray;
4839
- }
4840
- function scheduleRehydration(vm) {
4841
- if (isTrue(vm.isScheduled)) {
4842
- return;
4843
- }
4844
- vm.isScheduled = true;
4845
- if (rehydrateQueue.length === 0) {
4846
- addCallbackToNextTick(flushRehydrationQueue);
4847
- }
4848
- ArrayPush$1.call(rehydrateQueue, vm);
4849
- }
4850
- function getErrorBoundaryVM(vm) {
4851
- let currentVm = vm;
4852
- while (!isNull(currentVm)) {
4853
- if (!isUndefined$1(currentVm.def.errorCallback)) {
4854
- return currentVm;
4855
- }
4856
- currentVm = currentVm.owner;
4857
- }
4858
- }
4859
- function runWithBoundaryProtection(vm, owner, pre, job, post) {
4860
- let error;
4861
- pre();
4862
- try {
4863
- job();
4864
- } catch (e) {
4865
- error = Object(e);
4866
- } finally {
4867
- post();
4868
- if (!isUndefined$1(error)) {
4869
- addErrorComponentStack(vm, error);
4870
- const errorBoundaryVm = isNull(owner) ? undefined : getErrorBoundaryVM(owner);
4871
- if (isUndefined$1(errorBoundaryVm)) {
4872
- throw error; // eslint-disable-line no-unsafe-finally
4873
- }
4874
-
4875
- resetComponentRoot(vm); // remove offenders
4876
- logOperationStart(6 /* OperationId.ErrorCallback */, vm);
4877
- // error boundaries must have an ErrorCallback
4878
- const errorCallback = errorBoundaryVm.def.errorCallback;
4879
- invokeComponentCallback(errorBoundaryVm, errorCallback, [error, error.wcStack]);
4880
- logOperationEnd(6 /* OperationId.ErrorCallback */, vm);
4881
- }
4882
- }
4883
- }
4884
-
4885
- /*
4886
- * Copyright (c) 2018, salesforce.com, inc.
4887
- * All rights reserved.
4888
- * SPDX-License-Identifier: MIT
4889
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4890
- */
4891
- const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
4892
- const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
4893
- const WireMetaMap = new Map();
4894
- class WireContextRegistrationEvent extends CustomEvent {
4895
- constructor(adapterToken, {
4896
- setNewContext,
4897
- setDisconnectedCallback
4898
- }) {
4899
- super(adapterToken, {
4900
- bubbles: true,
4901
- composed: true
4902
- });
4903
- defineProperties(this, {
4904
- setNewContext: {
4905
- value: setNewContext
4906
- },
4907
- setDisconnectedCallback: {
4908
- value: setDisconnectedCallback
4909
- }
4910
- });
4911
- }
4912
- }
4913
- function createFieldDataCallback(vm, name) {
4914
- return value => {
4915
- updateComponentValue(vm, name, value);
4916
- };
4917
- }
4918
- function createMethodDataCallback(vm, method) {
4919
- return value => {
4920
- // dispatching new value into the wired method
4921
- runWithBoundaryProtection(vm, vm.owner, noop, () => {
4922
- // job
4923
- method.call(vm.component, value);
4924
- }, noop);
4925
- };
4926
- }
4927
- function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
4928
- let hasPendingConfig = false;
4929
- // creating the reactive observer for reactive params when needed
4930
- const ro = createReactiveObserver(() => {
4931
- if (hasPendingConfig === false) {
4932
- hasPendingConfig = true;
4933
- // collect new config in the micro-task
4934
- Promise.resolve().then(() => {
4935
- hasPendingConfig = false;
4936
- // resetting current reactive params
4937
- ro.reset();
4938
- // dispatching a new config due to a change in the configuration
4939
- computeConfigAndUpdate();
4940
- });
4941
- }
4942
- });
4943
- const computeConfigAndUpdate = () => {
4944
- let config;
4945
- ro.observe(() => config = configCallback(component));
4946
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
4947
- // TODO: dev-mode validation of config based on the adapter.configSchema
4948
- // @ts-ignore it is assigned in the observe() callback
4949
- callbackWhenConfigIsReady(config);
4950
- };
4951
- return {
4952
- computeConfigAndUpdate,
4953
- ro
4954
- };
4955
- }
4956
- function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
4957
- const {
4958
- adapter
4959
- } = wireDef;
4960
- const adapterContextToken = getAdapterToken(adapter);
4961
- if (isUndefined$1(adapterContextToken)) {
4962
- return; // no provider found, nothing to be done
5078
+ }
4963
5079
  }
4964
-
5080
+ }
5081
+ // This is a super optimized mechanism to remove the content of the root node (shadow root
5082
+ // for shadow DOM components and the root element itself for light DOM) without having to go
5083
+ // into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
5084
+ // children VNodes might not be representing the current state of the DOM.
5085
+ function resetComponentRoot(vm) {
4965
5086
  const {
4966
- elm,
4967
- context: {
4968
- wiredConnecting,
4969
- wiredDisconnecting
4970
- },
5087
+ children,
5088
+ renderRoot,
4971
5089
  renderer: {
4972
- dispatchEvent
5090
+ remove
4973
5091
  }
4974
5092
  } = vm;
4975
- // waiting for the component to be connected to formally request the context via the token
4976
- ArrayPush$1.call(wiredConnecting, () => {
4977
- // This event is responsible for connecting the host element with another
4978
- // element in the composed path that is providing contextual data. The provider
4979
- // must be listening for a special dom event with the name corresponding to the value of
4980
- // `adapterContextToken`, which will remain secret and internal to this file only to
4981
- // guarantee that the linkage can be forged.
4982
- const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
4983
- setNewContext(newContext) {
4984
- // eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
4985
- // TODO: dev-mode validation of config based on the adapter.contextSchema
4986
- callbackWhenContextIsReady(newContext);
4987
- },
4988
- setDisconnectedCallback(disconnectCallback) {
4989
- // adds this callback into the disconnect bucket so it gets disconnected from parent
4990
- // the the element hosting the wire is disconnected
4991
- ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
4992
- }
4993
- });
4994
- dispatchEvent(elm, contextRegistrationEvent);
4995
- });
4996
- }
4997
- function createConnector(vm, name, wireDef) {
4998
- const {
4999
- method,
5000
- adapter,
5001
- configCallback,
5002
- dynamic
5003
- } = wireDef;
5004
- let debugInfo;
5005
- const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
5006
- const dataCallback = value => {
5007
- fieldOrMethodCallback(value);
5008
- };
5009
- let context;
5010
- let connector;
5011
- // Workaround to pass the component element associated to this wire adapter instance.
5012
- defineProperty(dataCallback, DeprecatedWiredElementHost, {
5013
- value: vm.elm
5014
- });
5015
- defineProperty(dataCallback, DeprecatedWiredParamsMeta, {
5016
- value: dynamic
5017
- });
5018
- runWithBoundaryProtection(vm, vm, noop, () => {
5019
- // job
5020
- connector = new adapter(dataCallback);
5021
- }, noop);
5022
- const updateConnectorConfig = config => {
5023
- // every time the config is recomputed due to tracking,
5024
- // this callback will be invoked with the new computed config
5025
- runWithBoundaryProtection(vm, vm, noop, () => {
5026
- // job
5027
- if ("production" !== 'production') ;
5028
- connector.update(config, context);
5029
- }, noop);
5030
- };
5031
- // Computes the current wire config and calls the update method on the wire adapter.
5032
- // If it has params, we will need to observe changes in the next tick.
5033
- const {
5034
- computeConfigAndUpdate,
5035
- ro
5036
- } = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
5037
- // if the adapter needs contextualization, we need to watch for new context and push it alongside the config
5038
- if (!isUndefined$1(adapter.contextSchema)) {
5039
- createContextWatcher(vm, wireDef, newContext => {
5040
- // every time the context is pushed into this component,
5041
- // this callback will be invoked with the new computed context
5042
- if (context !== newContext) {
5043
- context = newContext;
5044
- // Note: when new context arrives, the config will be recomputed and pushed along side the new
5045
- // context, this is to preserve the identity characteristics, config should not have identity
5046
- // (ever), while context can have identity
5047
- if (vm.state === 1 /* VMState.connected */) {
5048
- computeConfigAndUpdate();
5049
- }
5050
- }
5051
- });
5093
+ for (let i = 0, len = children.length; i < len; i++) {
5094
+ const child = children[i];
5095
+ if (!isNull(child) && !isUndefined$1(child.elm)) {
5096
+ remove(child.elm, renderRoot);
5097
+ }
5052
5098
  }
5053
- return {
5054
- // @ts-ignore the boundary protection executes sync, connector is always defined
5055
- connector,
5056
- computeConfigAndUpdate,
5057
- resetConfigWatcher: () => ro.reset()
5058
- };
5059
- }
5060
- const AdapterToTokenMap = new Map();
5061
- function getAdapterToken(adapter) {
5062
- return AdapterToTokenMap.get(adapter);
5099
+ vm.children = EmptyArray;
5100
+ runChildNodesDisconnectedCallback(vm);
5101
+ vm.velements = EmptyArray;
5063
5102
  }
5064
- function setAdapterToken(adapter, token) {
5065
- AdapterToTokenMap.set(adapter, token);
5103
+ function scheduleRehydration(vm) {
5104
+ if (isTrue(vm.isScheduled)) {
5105
+ return;
5106
+ }
5107
+ vm.isScheduled = true;
5108
+ if (rehydrateQueue.length === 0) {
5109
+ addCallbackToNextTick(flushRehydrationQueue);
5110
+ }
5111
+ ArrayPush$1.call(rehydrateQueue, vm);
5066
5112
  }
5067
- function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
5068
- // support for callable adapters
5069
- if (adapter.adapter) {
5070
- adapter = adapter.adapter;
5113
+ function getErrorBoundaryVM(vm) {
5114
+ let currentVm = vm;
5115
+ while (!isNull(currentVm)) {
5116
+ if (!isUndefined$1(currentVm.def.errorCallback)) {
5117
+ return currentVm;
5118
+ }
5119
+ currentVm = currentVm.owner;
5071
5120
  }
5072
- const method = descriptor.value;
5073
- const def = {
5074
- adapter,
5075
- method,
5076
- configCallback,
5077
- dynamic
5078
- };
5079
- WireMetaMap.set(descriptor, def);
5080
5121
  }
5081
- function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
5082
- // support for callable adapters
5083
- if (adapter.adapter) {
5084
- adapter = adapter.adapter;
5122
+ function runWithBoundaryProtection(vm, owner, pre, job, post) {
5123
+ let error;
5124
+ pre();
5125
+ try {
5126
+ job();
5127
+ } catch (e) {
5128
+ error = Object(e);
5129
+ } finally {
5130
+ post();
5131
+ if (!isUndefined$1(error)) {
5132
+ addErrorComponentStack(vm, error);
5133
+ const errorBoundaryVm = isNull(owner) ? undefined : getErrorBoundaryVM(owner);
5134
+ if (isUndefined$1(errorBoundaryVm)) {
5135
+ throw error; // eslint-disable-line no-unsafe-finally
5136
+ }
5137
+
5138
+ resetComponentRoot(vm); // remove offenders
5139
+ logOperationStart(6 /* OperationId.ErrorCallback */, vm);
5140
+ // error boundaries must have an ErrorCallback
5141
+ const errorCallback = errorBoundaryVm.def.errorCallback;
5142
+ invokeComponentCallback(errorBoundaryVm, errorCallback, [error, error.wcStack]);
5143
+ logOperationEnd(6 /* OperationId.ErrorCallback */, vm);
5144
+ }
5085
5145
  }
5086
- const def = {
5087
- adapter,
5088
- configCallback,
5089
- dynamic
5090
- };
5091
- WireMetaMap.set(descriptor, def);
5092
5146
  }
5093
- function installWireAdapters(vm) {
5094
- const {
5095
- context,
5096
- def: {
5097
- wire
5147
+
5148
+ /*
5149
+ * Copyright (c) 2018, salesforce.com, inc.
5150
+ * All rights reserved.
5151
+ * SPDX-License-Identifier: MIT
5152
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5153
+ */
5154
+ //
5155
+ // The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
5156
+ // These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
5157
+ // When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
5158
+ // See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
5159
+ //
5160
+ // Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
5161
+ const getElementById = _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
5162
+ const querySelectorAll = _globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
5163
+ function isSyntheticShadowRootInstance(rootNode) {
5164
+ return rootNode !== document && isTrue(rootNode.synthetic);
5165
+ }
5166
+ function reportViolation(source, target, attrName) {
5167
+ // The vm is either for the source, the target, or both. Either one or both must be using synthetic
5168
+ // shadow for a violation to be detected.
5169
+ let vm = getAssociatedVMIfPresent(source.getRootNode().host);
5170
+ if (isUndefined$1(vm)) {
5171
+ vm = getAssociatedVMIfPresent(target.getRootNode().host);
5172
+ }
5173
+ if (isUndefined$1(vm)) {
5174
+ // vm should never be undefined here, but just to be safe, bail out and don't report
5175
+ return;
5098
5176
  }
5099
- } = vm;
5100
- const wiredConnecting = context.wiredConnecting = [];
5101
- const wiredDisconnecting = context.wiredDisconnecting = [];
5102
- for (const fieldNameOrMethod in wire) {
5103
- const descriptor = wire[fieldNameOrMethod];
5104
- const wireDef = WireMetaMap.get(descriptor);
5105
- if (!isUndefined$1(wireDef)) {
5106
- const {
5107
- connector,
5108
- computeConfigAndUpdate,
5109
- resetConfigWatcher
5110
- } = createConnector(vm, fieldNameOrMethod, wireDef);
5111
- const hasDynamicParams = wireDef.dynamic.length > 0;
5112
- ArrayPush$1.call(wiredConnecting, () => {
5113
- connector.connect();
5114
- if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
5115
- if (hasDynamicParams) {
5116
- Promise.resolve().then(computeConfigAndUpdate);
5177
+ report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
5178
+ }
5179
+ function parseIdRefAttributeValue(attrValue) {
5180
+ // split on whitespace and skip empty strings after splitting
5181
+ return isString(attrValue) ? ArrayFilter.call(StringSplit.call(attrValue, /\s+/), Boolean) : [];
5182
+ }
5183
+ function detectSyntheticCrossRootAria(elm, attrName, attrValue) {
5184
+ const root = elm.getRootNode();
5185
+ if (!isSyntheticShadowRootInstance(root)) {
5186
+ return;
5187
+ }
5188
+ if (attrName === 'id') {
5189
+ // elm is the target, find the source
5190
+ if (!isString(attrValue) || attrValue.length === 0) {
5191
+ // if our id is null or empty, nobody can reference us
5117
5192
  return;
5118
- }
5119
5193
  }
5120
- computeConfigAndUpdate();
5121
- });
5122
- ArrayPush$1.call(wiredDisconnecting, () => {
5123
- connector.disconnect();
5124
- resetConfigWatcher();
5125
- });
5194
+ for (const idRefAttrName of ID_REFERENCING_ATTRIBUTES_SET) {
5195
+ // Query all global elements with this attribute. The attribute selector syntax `~=` is for values
5196
+ // that reference multiple IDs, separated by whitespace.
5197
+ const query = `[${idRefAttrName}~="${CSS.escape(attrValue)}"]`;
5198
+ const sourceElements = querySelectorAll.call(document, query);
5199
+ for (let i = 0; i < sourceElements.length; i++) {
5200
+ const sourceElement = sourceElements[i];
5201
+ const sourceRoot = sourceElement.getRootNode();
5202
+ if (sourceRoot !== root) {
5203
+ reportViolation(sourceElement, elm);
5204
+ break;
5205
+ }
5206
+ }
5207
+ }
5208
+ }
5209
+ else {
5210
+ // elm is the source, find the target
5211
+ const ids = parseIdRefAttributeValue(attrValue);
5212
+ for (const id of ids) {
5213
+ const target = getElementById.call(document, id);
5214
+ if (!isNull(target)) {
5215
+ const targetRoot = target.getRootNode();
5216
+ if (targetRoot !== root) {
5217
+ // target element's shadow root is not the same as ours
5218
+ reportViolation(elm, target);
5219
+ }
5220
+ }
5221
+ }
5126
5222
  }
5127
- }
5128
5223
  }
5129
- function connectWireAdapters(vm) {
5130
- const {
5131
- wiredConnecting
5132
- } = vm.context;
5133
- for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
5134
- wiredConnecting[i]();
5135
- }
5224
+ let enabled = false;
5225
+ // We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
5226
+ // reporting is not enabled. It should also only run once
5227
+ function enableDetection() {
5228
+ if (enabled) {
5229
+ return; // don't double-apply the patches
5230
+ }
5231
+ enabled = true;
5232
+ const { setAttribute } = Element.prototype;
5233
+ // Detect calling `setAttribute` to set an idref or an id
5234
+ assign(Element.prototype, {
5235
+ setAttribute(attrName, attrValue) {
5236
+ setAttribute.call(this, attrName, attrValue);
5237
+ if (attrName === 'id' || ID_REFERENCING_ATTRIBUTES_SET.has(attrName)) {
5238
+ detectSyntheticCrossRootAria(this, attrName, attrValue);
5239
+ }
5240
+ },
5241
+ });
5242
+ // Detect `elm.id = 'foo'`
5243
+ const idDescriptor = getOwnPropertyDescriptor$1(Element.prototype, 'id');
5244
+ if (!isUndefined$1(idDescriptor)) {
5245
+ const { get, set } = idDescriptor;
5246
+ // These should always be a getter and a setter, but if someone is monkeying with the global descriptor, ignore it
5247
+ if (isFunction$1(get) && isFunction$1(set)) {
5248
+ defineProperty(Element.prototype, 'id', {
5249
+ get() {
5250
+ return get.call(this);
5251
+ },
5252
+ set(value) {
5253
+ set.call(this, value);
5254
+ detectSyntheticCrossRootAria(this, 'id', value);
5255
+ },
5256
+ // On the default descriptor for 'id', enumerable and configurable are true
5257
+ enumerable: true,
5258
+ configurable: true,
5259
+ });
5260
+ }
5261
+ }
5136
5262
  }
5137
- function disconnectWireAdapters(vm) {
5138
- const {
5139
- wiredDisconnecting
5140
- } = vm.context;
5141
- runWithBoundaryProtection(vm, vm, noop, () => {
5142
- // job
5143
- for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
5144
- wiredDisconnecting[i]();
5263
+ // Our detection logic relies on some modern browser features. We can just skip reporting the data
5264
+ // for unsupported browsers
5265
+ function supportsCssEscape() {
5266
+ return typeof CSS !== 'undefined' && isFunction$1(CSS.escape);
5267
+ }
5268
+ // If this page is not using synthetic shadow, then we don't need to install detection. Note
5269
+ // that we are assuming synthetic shadow is loaded before LWC.
5270
+ function isSyntheticShadowLoaded() {
5271
+ // We should probably be calling `renderer.isSyntheticShadowDefined`, but 1) we don't have access to the renderer,
5272
+ // and 2) this code needs to run in @lwc/engine-core, so it can access `logWarn()` and `report()`.
5273
+ return hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
5274
+ }
5275
+ // Detecting cross-root ARIA in synthetic shadow only makes sense for the browser
5276
+ if (supportsCssEscape() && isSyntheticShadowLoaded()) {
5277
+ // Always run detection in dev mode, so we can at least print to the console
5278
+ {
5279
+ // In prod mode, only enable detection if reporting is enabled
5280
+ onReportingEnabled(enableDetection);
5145
5281
  }
5146
- }, noop);
5147
5282
  }
5148
5283
 
5149
5284
  /*
@@ -6511,7 +6646,7 @@ var LWC = (function (exports) {
6511
6646
  function isNull(obj) {
6512
6647
  return obj === null;
6513
6648
  }
6514
- /** version: 2.34.0 */
6649
+ /** version: 2.35.0 */
6515
6650
 
6516
6651
  /*
6517
6652
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7064,10 +7199,11 @@ var LWC = (function (exports) {
7064
7199
  });
7065
7200
  freeze(LightningElement);
7066
7201
  seal(LightningElement.prototype);
7067
- /* version: 2.34.0 */
7202
+ /* version: 2.35.0 */
7068
7203
 
7069
7204
  exports.LightningElement = LightningElement;
7070
7205
  exports.__unstable__ProfilerControl = profilerControl;
7206
+ exports.__unstable__ReportingControl = reportingControl;
7071
7207
  exports.api = api$1;
7072
7208
  exports.buildCustomElementConstructor = deprecatedBuildCustomElementConstructor;
7073
7209
  exports.createContextProvider = createContextProvider;