lwc 2.34.0 → 2.35.0

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