@lwc/engine-core 2.6.2 → 2.6.3

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.
@@ -73,6 +73,170 @@ function parseStyleText(cssText) {
73
73
  return styleMap;
74
74
  }
75
75
 
76
+ //
77
+ // Primitives
78
+ //
79
+ let ssr;
80
+ function setSsr(ssrImpl) {
81
+ ssr = ssrImpl;
82
+ }
83
+ let isNativeShadowDefined;
84
+ function setIsNativeShadowDefined(isNativeShadowDefinedImpl) {
85
+ isNativeShadowDefined = isNativeShadowDefinedImpl;
86
+ }
87
+ let isSyntheticShadowDefined;
88
+ function setIsSyntheticShadowDefined(isSyntheticShadowDefinedImpl) {
89
+ isSyntheticShadowDefined = isSyntheticShadowDefinedImpl;
90
+ }
91
+ let HTMLElementExported;
92
+ function setHTMLElement(HTMLElementImpl) {
93
+ HTMLElementExported = HTMLElementImpl;
94
+ }
95
+ let isHydrating;
96
+ function setIsHydrating(isHydratingImpl) {
97
+ isHydrating = isHydratingImpl;
98
+ }
99
+ let insert;
100
+ function setInsert(insertImpl) {
101
+ insert = insertImpl;
102
+ }
103
+ let remove;
104
+ function setRemove(removeImpl) {
105
+ remove = removeImpl;
106
+ }
107
+ let createElement;
108
+ function setCreateElement(createElementImpl) {
109
+ createElement = createElementImpl;
110
+ }
111
+ let createText;
112
+ function setCreateText(createTextImpl) {
113
+ createText = createTextImpl;
114
+ }
115
+ let createComment;
116
+ function setCreateComment(createCommentImpl) {
117
+ createComment = createCommentImpl;
118
+ }
119
+ let nextSibling;
120
+ function setNextSibling(nextSiblingImpl) {
121
+ nextSibling = nextSiblingImpl;
122
+ }
123
+ let attachShadow;
124
+ function setAttachShadow(attachShadowImpl) {
125
+ attachShadow = attachShadowImpl;
126
+ }
127
+ let getProperty;
128
+ function setGetProperty(getPropertyImpl) {
129
+ getProperty = getPropertyImpl;
130
+ }
131
+ let setProperty;
132
+ function setSetProperty(setPropertyImpl) {
133
+ setProperty = setPropertyImpl;
134
+ }
135
+ let setText;
136
+ function setSetText(setTextImpl) {
137
+ setText = setTextImpl;
138
+ }
139
+ let getAttribute;
140
+ function setGetAttribute(getAttributeImpl) {
141
+ getAttribute = getAttributeImpl;
142
+ }
143
+ let setAttribute;
144
+ function setSetAttribute(setAttributeImpl) {
145
+ setAttribute = setAttributeImpl;
146
+ }
147
+ let removeAttribute;
148
+ function setRemoveAttribute(removeAttributeImpl) {
149
+ removeAttribute = removeAttributeImpl;
150
+ }
151
+ let addEventListener;
152
+ function setAddEventListener(addEventListenerImpl) {
153
+ addEventListener = addEventListenerImpl;
154
+ }
155
+ let removeEventListener;
156
+ function setRemoveEventListener(removeEventListenerImpl) {
157
+ removeEventListener = removeEventListenerImpl;
158
+ }
159
+ let dispatchEvent;
160
+ function setDispatchEvent(dispatchEventImpl) {
161
+ dispatchEvent = dispatchEventImpl;
162
+ }
163
+ let getClassList;
164
+ function setGetClassList(getClassListImpl) {
165
+ getClassList = getClassListImpl;
166
+ }
167
+ let setCSSStyleProperty;
168
+ function setSetCSSStyleProperty(setCSSStylePropertyImpl) {
169
+ setCSSStyleProperty = setCSSStylePropertyImpl;
170
+ }
171
+ let getBoundingClientRect;
172
+ function setGetBoundingClientRect(getBoundingClientRectImpl) {
173
+ getBoundingClientRect = getBoundingClientRectImpl;
174
+ }
175
+ let querySelector;
176
+ function setQuerySelector(querySelectorImpl) {
177
+ querySelector = querySelectorImpl;
178
+ }
179
+ let querySelectorAll;
180
+ function setQuerySelectorAll(querySelectorAllImpl) {
181
+ querySelectorAll = querySelectorAllImpl;
182
+ }
183
+ let getElementsByTagName;
184
+ function setGetElementsByTagName(getElementsByTagNameImpl) {
185
+ getElementsByTagName = getElementsByTagNameImpl;
186
+ }
187
+ let getElementsByClassName;
188
+ function setGetElementsByClassName(getElementsByClassNameImpl) {
189
+ getElementsByClassName = getElementsByClassNameImpl;
190
+ }
191
+ let getChildren;
192
+ function setGetChildren(getChildrenImpl) {
193
+ getChildren = getChildrenImpl;
194
+ }
195
+ let getChildNodes;
196
+ function setGetChildNodes(getChildNodesImpl) {
197
+ getChildNodes = getChildNodesImpl;
198
+ }
199
+ let getFirstChild;
200
+ function setGetFirstChild(getFirstChildImpl) {
201
+ getFirstChild = getFirstChildImpl;
202
+ }
203
+ let getFirstElementChild;
204
+ function setGetFirstElementChild(getFirstElementChildImpl) {
205
+ getFirstElementChild = getFirstElementChildImpl;
206
+ }
207
+ let getLastChild;
208
+ function setGetLastChild(getLastChildImpl) {
209
+ getLastChild = getLastChildImpl;
210
+ }
211
+ let getLastElementChild;
212
+ function setGetLastElementChild(getLastElementChildImpl) {
213
+ getLastElementChild = getLastElementChildImpl;
214
+ }
215
+ let isConnected;
216
+ function setIsConnected(isConnectedImpl) {
217
+ isConnected = isConnectedImpl;
218
+ }
219
+ let insertGlobalStylesheet;
220
+ function setInsertGlobalStylesheet(insertGlobalStylesheetImpl) {
221
+ insertGlobalStylesheet = insertGlobalStylesheetImpl;
222
+ }
223
+ let insertStylesheet;
224
+ function setInsertStylesheet(insertStylesheetImpl) {
225
+ insertStylesheet = insertStylesheetImpl;
226
+ }
227
+ let assertInstanceOfHTMLElement;
228
+ function setAssertInstanceOfHTMLElement(assertInstanceOfHTMLElementImpl) {
229
+ assertInstanceOfHTMLElement = assertInstanceOfHTMLElementImpl;
230
+ }
231
+ let defineCustomElement;
232
+ function setDefineCustomElement(defineCustomElementImpl) {
233
+ defineCustomElement = defineCustomElementImpl;
234
+ }
235
+ let getCustomElement;
236
+ function setGetCustomElement(getCustomElementImpl) {
237
+ getCustomElement = getCustomElementImpl;
238
+ }
239
+
76
240
  /*
77
241
  * Copyright (c) 2019, salesforce.com, inc.
78
242
  * All rights reserved.
@@ -314,9 +478,6 @@ function createAllEventListeners(vnode) {
314
478
  elm,
315
479
  data: {
316
480
  on
317
- },
318
- owner: {
319
- renderer
320
481
  }
321
482
  } = vnode;
322
483
 
@@ -329,7 +490,7 @@ function createAllEventListeners(vnode) {
329
490
  let name;
330
491
 
331
492
  for (name in on) {
332
- renderer.addEventListener(elm, name, listener);
493
+ addEventListener(elm, name, listener);
333
494
  }
334
495
  }
335
496
 
@@ -468,9 +629,6 @@ function updateAttrs(oldVnode, vnode) {
468
629
  const {
469
630
  data: {
470
631
  attrs
471
- },
472
- owner: {
473
- renderer
474
632
  }
475
633
  } = vnode;
476
634
 
@@ -493,10 +651,6 @@ function updateAttrs(oldVnode, vnode) {
493
651
  }
494
652
 
495
653
  const elm = vnode.elm;
496
- const {
497
- setAttribute,
498
- removeAttribute
499
- } = renderer;
500
654
  let key;
501
655
  oldAttrs = shared.isUndefined(oldAttrs) ? EmptyObject : oldAttrs; // update modified attributes, add new attributes
502
656
  // this routine is only useful for data-* attributes in all kind of elements
@@ -515,7 +669,7 @@ function updateAttrs(oldVnode, vnode) {
515
669
  } else if (shared.StringCharCodeAt.call(key, 5) === ColonCharCode) {
516
670
  // Assume xlink namespace
517
671
  setAttribute(elm, key, cur, xlinkNS);
518
- } else if (shared.isNull(cur)) {
672
+ } else if (shared.isNull(cur) || shared.isUndefined(cur)) {
519
673
  removeAttribute(elm, key);
520
674
  } else {
521
675
  setAttribute(elm, key, cur);
@@ -567,17 +721,14 @@ function update(oldVnode, vnode) {
567
721
  const isFirstPatch = shared.isUndefined(oldProps);
568
722
  const {
569
723
  elm,
570
- sel,
571
- owner: {
572
- renderer
573
- }
724
+ sel
574
725
  } = vnode;
575
726
 
576
727
  for (const key in props) {
577
728
  const cur = props[key]; // if it is the first time this element is patched, or the current value is different to the previous value...
578
729
 
579
- if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? renderer.getProperty(elm, key) : oldProps[key])) {
580
- renderer.setProperty(elm, key, cur);
730
+ if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
731
+ setProperty(elm, key, cur);
581
732
  }
582
733
  }
583
734
  }
@@ -646,9 +797,6 @@ function updateClassAttribute(oldVnode, vnode) {
646
797
  elm,
647
798
  data: {
648
799
  className: newClass
649
- },
650
- owner: {
651
- renderer
652
800
  }
653
801
  } = vnode;
654
802
  const {
@@ -661,7 +809,7 @@ function updateClassAttribute(oldVnode, vnode) {
661
809
  return;
662
810
  }
663
811
 
664
- const classList = renderer.getClassList(elm);
812
+ const classList = getClassList(elm);
665
813
  const newClassMap = getMapFromClassName(newClass);
666
814
  const oldClassMap = getMapFromClassName(oldClass);
667
815
  let name;
@@ -700,15 +848,8 @@ function updateStyleAttribute(oldVnode, vnode) {
700
848
  elm,
701
849
  data: {
702
850
  style: newStyle
703
- },
704
- owner: {
705
- renderer
706
851
  }
707
852
  } = vnode;
708
- const {
709
- setAttribute,
710
- removeAttribute
711
- } = renderer;
712
853
 
713
854
  if (oldVnode.data.style === newStyle) {
714
855
  return;
@@ -743,9 +884,6 @@ function createClassAttribute(vnode) {
743
884
  elm,
744
885
  data: {
745
886
  classMap
746
- },
747
- owner: {
748
- renderer
749
887
  }
750
888
  } = vnode;
751
889
 
@@ -753,7 +891,7 @@ function createClassAttribute(vnode) {
753
891
  return;
754
892
  }
755
893
 
756
- const classList = renderer.getClassList(elm);
894
+ const classList = getClassList(elm);
757
895
 
758
896
  for (const name in classMap) {
759
897
  classList.add(name);
@@ -778,9 +916,6 @@ function createStyleAttribute(vnode) {
778
916
  elm,
779
917
  data: {
780
918
  styleDecls
781
- },
782
- owner: {
783
- renderer
784
919
  }
785
920
  } = vnode;
786
921
 
@@ -790,7 +925,7 @@ function createStyleAttribute(vnode) {
790
925
 
791
926
  for (let i = 0; i < styleDecls.length; i++) {
792
927
  const [prop, value, important] = styleDecls[i];
793
- renderer.setCSSStyleProperty(elm, prop, value, important);
928
+ setCSSStyleProperty(elm, prop, value, important);
794
929
  }
795
930
  }
796
931
 
@@ -805,14 +940,6 @@ var modStaticStyle = {
805
940
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
806
941
  */
807
942
 
808
- /**
809
- @license
810
- Copyright (c) 2015 Simon Friis Vindum.
811
- This code may only be used under the MIT License found at
812
- https://github.com/snabbdom/snabbdom/blob/master/LICENSE
813
- Code distributed by Snabbdom as part of the Snabbdom project at
814
- https://github.com/snabbdom/snabbdom/
815
- */
816
943
  function isUndef(s) {
817
944
  return s === undefined;
818
945
  }
@@ -900,7 +1027,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
900
1027
  } else if (sameVnode(oldStartVnode, newEndVnode)) {
901
1028
  // Vnode moved right
902
1029
  patchVnode(oldStartVnode, newEndVnode);
903
- newEndVnode.hook.move(oldStartVnode, parentElm, oldEndVnode.owner.renderer.nextSibling(oldEndVnode.elm));
1030
+ newEndVnode.hook.move(oldStartVnode, parentElm, nextSibling(oldEndVnode.elm));
904
1031
  oldStartVnode = oldCh[++oldStartIdx];
905
1032
  newEndVnode = newCh[--newEndIdx];
906
1033
  } else if (sameVnode(oldEndVnode, newStartVnode)) {
@@ -1377,7 +1504,7 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
1377
1504
  }
1378
1505
 
1379
1506
  /*
1380
- * Copyright (c) 2020, salesforce.com, inc.
1507
+ * Copyright (c) 2018, salesforce.com, inc.
1381
1508
  * All rights reserved.
1382
1509
  * SPDX-License-Identifier: MIT
1383
1510
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -2292,9 +2419,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
2292
2419
 
2293
2420
 
2294
2421
  const LightningElement = function () {
2295
- var _a; // This should be as performant as possible, while any initialization should be done lazily
2296
-
2297
-
2422
+ // This should be as performant as possible, while any initialization should be done lazily
2298
2423
  if (shared.isNull(vmBeingConstructed)) {
2299
2424
  throw new ReferenceError('Illegal constructor');
2300
2425
  }
@@ -2302,15 +2427,14 @@ const LightningElement = function () {
2302
2427
  const vm = vmBeingConstructed;
2303
2428
  const {
2304
2429
  def,
2305
- elm,
2306
- renderer
2430
+ elm
2307
2431
  } = vm;
2308
2432
  const {
2309
2433
  bridge
2310
2434
  } = def;
2311
2435
 
2312
2436
  if (process.env.NODE_ENV !== 'production') {
2313
- (_a = renderer.assertInstanceOfHTMLElement) === null || _a === void 0 ? void 0 : _a.call(renderer, vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
2437
+ assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
2314
2438
  }
2315
2439
 
2316
2440
  const component = this;
@@ -2340,7 +2464,7 @@ const LightningElement = function () {
2340
2464
  if (vm.renderMode === 1
2341
2465
  /* Shadow */
2342
2466
  ) {
2343
- attachShadow(vm);
2467
+ doAttachShadow(vm);
2344
2468
  } // Adding extra guard rails in DEV mode.
2345
2469
 
2346
2470
 
@@ -2352,17 +2476,16 @@ const LightningElement = function () {
2352
2476
  return this;
2353
2477
  };
2354
2478
 
2355
- function attachShadow(vm) {
2479
+ function doAttachShadow(vm) {
2356
2480
  const {
2357
2481
  elm,
2358
2482
  mode,
2359
- renderer,
2360
2483
  shadowMode,
2361
2484
  def: {
2362
2485
  ctor
2363
2486
  }
2364
2487
  } = vm;
2365
- const cmpRoot = renderer.attachShadow(elm, {
2488
+ const cmpRoot = attachShadow(elm, {
2366
2489
  [shared.KEY__SYNTHETIC_MODE]: shadowMode === 1
2367
2490
  /* Synthetic */
2368
2491
  ,
@@ -2389,10 +2512,7 @@ LightningElement.prototype = {
2389
2512
 
2390
2513
  dispatchEvent(event) {
2391
2514
  const {
2392
- elm,
2393
- renderer: {
2394
- dispatchEvent
2395
- }
2515
+ elm
2396
2516
  } = getAssociatedVM(this);
2397
2517
  return dispatchEvent(elm, event);
2398
2518
  },
@@ -2400,10 +2520,7 @@ LightningElement.prototype = {
2400
2520
  addEventListener(type, listener, options) {
2401
2521
  const vm = getAssociatedVM(this);
2402
2522
  const {
2403
- elm,
2404
- renderer: {
2405
- addEventListener
2406
- }
2523
+ elm
2407
2524
  } = vm;
2408
2525
 
2409
2526
  if (process.env.NODE_ENV !== 'production') {
@@ -2420,10 +2537,7 @@ LightningElement.prototype = {
2420
2537
  removeEventListener(type, listener, options) {
2421
2538
  const vm = getAssociatedVM(this);
2422
2539
  const {
2423
- elm,
2424
- renderer: {
2425
- removeEventListener
2426
- }
2540
+ elm
2427
2541
  } = vm;
2428
2542
  const wrappedListener = getWrappedComponentsListener(vm, listener);
2429
2543
  removeEventListener(elm, type, wrappedListener, options);
@@ -2431,30 +2545,21 @@ LightningElement.prototype = {
2431
2545
 
2432
2546
  hasAttribute(name) {
2433
2547
  const {
2434
- elm,
2435
- renderer: {
2436
- getAttribute
2437
- }
2548
+ elm
2438
2549
  } = getAssociatedVM(this);
2439
2550
  return !shared.isNull(getAttribute(elm, name));
2440
2551
  },
2441
2552
 
2442
2553
  hasAttributeNS(namespace, name) {
2443
2554
  const {
2444
- elm,
2445
- renderer: {
2446
- getAttribute
2447
- }
2555
+ elm
2448
2556
  } = getAssociatedVM(this);
2449
2557
  return !shared.isNull(getAttribute(elm, name, namespace));
2450
2558
  },
2451
2559
 
2452
2560
  removeAttribute(name) {
2453
2561
  const {
2454
- elm,
2455
- renderer: {
2456
- removeAttribute
2457
- }
2562
+ elm
2458
2563
  } = getAssociatedVM(this);
2459
2564
  unlockAttribute(elm, name);
2460
2565
  removeAttribute(elm, name);
@@ -2463,10 +2568,7 @@ LightningElement.prototype = {
2463
2568
 
2464
2569
  removeAttributeNS(namespace, name) {
2465
2570
  const {
2466
- elm,
2467
- renderer: {
2468
- removeAttribute
2469
- }
2571
+ elm
2470
2572
  } = getAssociatedVM(this);
2471
2573
  unlockAttribute(elm, name);
2472
2574
  removeAttribute(elm, name, namespace);
@@ -2475,20 +2577,14 @@ LightningElement.prototype = {
2475
2577
 
2476
2578
  getAttribute(name) {
2477
2579
  const {
2478
- elm,
2479
- renderer: {
2480
- getAttribute
2481
- }
2580
+ elm
2482
2581
  } = getAssociatedVM(this);
2483
2582
  return getAttribute(elm, name);
2484
2583
  },
2485
2584
 
2486
2585
  getAttributeNS(namespace, name) {
2487
2586
  const {
2488
- elm,
2489
- renderer: {
2490
- getAttribute
2491
- }
2587
+ elm
2492
2588
  } = getAssociatedVM(this);
2493
2589
  return getAttribute(elm, name, namespace);
2494
2590
  },
@@ -2496,10 +2592,7 @@ LightningElement.prototype = {
2496
2592
  setAttribute(name, value) {
2497
2593
  const vm = getAssociatedVM(this);
2498
2594
  const {
2499
- elm,
2500
- renderer: {
2501
- setAttribute
2502
- }
2595
+ elm
2503
2596
  } = vm;
2504
2597
 
2505
2598
  if (process.env.NODE_ENV !== 'production') {
@@ -2514,10 +2607,7 @@ LightningElement.prototype = {
2514
2607
  setAttributeNS(namespace, name, value) {
2515
2608
  const vm = getAssociatedVM(this);
2516
2609
  const {
2517
- elm,
2518
- renderer: {
2519
- setAttribute
2520
- }
2610
+ elm
2521
2611
  } = vm;
2522
2612
 
2523
2613
  if (process.env.NODE_ENV !== 'production') {
@@ -2532,10 +2622,7 @@ LightningElement.prototype = {
2532
2622
  getBoundingClientRect() {
2533
2623
  const vm = getAssociatedVM(this);
2534
2624
  const {
2535
- elm,
2536
- renderer: {
2537
- getBoundingClientRect
2538
- }
2625
+ elm
2539
2626
  } = vm;
2540
2627
 
2541
2628
  if (process.env.NODE_ENV !== 'production') {
@@ -2547,10 +2634,7 @@ LightningElement.prototype = {
2547
2634
 
2548
2635
  get isConnected() {
2549
2636
  const {
2550
- elm,
2551
- renderer: {
2552
- isConnected
2553
- }
2637
+ elm
2554
2638
  } = getAssociatedVM(this);
2555
2639
  return isConnected(elm);
2556
2640
  },
@@ -2558,10 +2642,7 @@ LightningElement.prototype = {
2558
2642
  get classList() {
2559
2643
  const vm = getAssociatedVM(this);
2560
2644
  const {
2561
- elm,
2562
- renderer: {
2563
- getClassList
2564
- }
2645
+ elm
2565
2646
  } = vm;
2566
2647
 
2567
2648
  if (process.env.NODE_ENV !== 'production') {
@@ -2604,23 +2685,48 @@ LightningElement.prototype = {
2604
2685
  }
2605
2686
 
2606
2687
  };
2607
- const queryAndChildGetterDescriptors = shared.create(null);
2608
- const childGetters = [['children', 'getChildren'], ['childNodes', 'getChildNodes'], ['firstChild', 'getFirstChild'], ['firstElementChild', 'getFirstElementChild'], ['lastChild', 'getLastChild'], ['lastElementChild', 'getLastElementChild']]; // Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
2688
+ const queryAndChildGetterDescriptors = shared.create(null); // The reason we don't just call `import * as renderer from '../renderer'` here is that the bundle size
2689
+ // is smaller if we reference each function individually. Otherwise Rollup will create one big frozen
2690
+ // object representing the renderer, with a lot of methods we don't actually need.
2691
+
2692
+ const childGetters = ['children', 'childNodes', 'firstChild', 'firstElementChild', 'lastChild', 'lastElementChild'];
2693
+
2694
+ function getChildGetter(methodName) {
2695
+ switch (methodName) {
2696
+ case 'children':
2697
+ return getChildren;
2698
+
2699
+ case 'childNodes':
2700
+ return getChildNodes;
2701
+
2702
+ case 'firstChild':
2703
+ return getFirstChild;
2704
+
2705
+ case 'firstElementChild':
2706
+ return getFirstElementChild;
2609
2707
 
2610
- for (const [elementProp, rendererMethod] of childGetters) {
2611
- queryAndChildGetterDescriptors[elementProp] = {
2708
+ case 'lastChild':
2709
+ return getLastChild;
2710
+
2711
+ case 'lastElementChild':
2712
+ return getLastElementChild;
2713
+ }
2714
+ } // Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
2715
+
2716
+
2717
+ for (const childGetter of childGetters) {
2718
+ queryAndChildGetterDescriptors[childGetter] = {
2612
2719
  get() {
2613
2720
  const vm = getAssociatedVM(this);
2614
2721
  const {
2615
- elm,
2616
- renderer
2722
+ elm
2617
2723
  } = vm;
2618
2724
 
2619
2725
  if (process.env.NODE_ENV !== 'production') {
2620
- warnIfInvokedDuringConstruction(vm, elementProp);
2726
+ warnIfInvokedDuringConstruction(vm, childGetter);
2621
2727
  }
2622
2728
 
2623
- return renderer[rendererMethod](elm);
2729
+ return getChildGetter(childGetter)(elm);
2624
2730
  },
2625
2731
 
2626
2732
  configurable: true,
@@ -2628,22 +2734,38 @@ for (const [elementProp, rendererMethod] of childGetters) {
2628
2734
  };
2629
2735
  }
2630
2736
 
2631
- const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll']; // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
2737
+ const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
2738
+
2739
+ function getQueryMethod(methodName) {
2740
+ switch (methodName) {
2741
+ case 'getElementsByClassName':
2742
+ return getElementsByClassName;
2743
+
2744
+ case 'getElementsByTagName':
2745
+ return getElementsByTagName;
2746
+
2747
+ case 'querySelector':
2748
+ return querySelector;
2749
+
2750
+ case 'querySelectorAll':
2751
+ return querySelectorAll;
2752
+ }
2753
+ } // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
2754
+
2632
2755
 
2633
2756
  for (const queryMethod of queryMethods) {
2634
2757
  queryAndChildGetterDescriptors[queryMethod] = {
2635
2758
  value(arg) {
2636
2759
  const vm = getAssociatedVM(this);
2637
2760
  const {
2638
- elm,
2639
- renderer
2761
+ elm
2640
2762
  } = vm;
2641
2763
 
2642
2764
  if (process.env.NODE_ENV !== 'production') {
2643
2765
  warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
2644
2766
  }
2645
2767
 
2646
- return renderer[queryMethod](elm, arg);
2768
+ return getQueryMethod(queryMethod)(elm, arg);
2647
2769
  },
2648
2770
 
2649
2771
  configurable: true,
@@ -3773,10 +3895,6 @@ function createComponentDef(Ctor) {
3773
3895
 
3774
3896
  shared.assert.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
3775
3897
 
3776
- if (!features.runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
3777
- shared.assert.isFalse('shadowSupportMode' in Ctor, `${ctorName || 'Anonymous class'} is an invalid LWC component. The shadowSupportMode static property is not available in this environment.`);
3778
- }
3779
-
3780
3898
  if (!shared.isUndefined(ctorShadowSupportMode)) {
3781
3899
  shared.assert.invariant(ctorShadowSupportMode === "any"
3782
3900
  /* Any */
@@ -4018,17 +4136,14 @@ function setScopeTokenClassIfNecessary(elm, owner) {
4018
4136
  const token = cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken;
4019
4137
 
4020
4138
  if (!shared.isUndefined(token) && context.hasScopedStyles) {
4021
- owner.renderer.getClassList(elm).add(token);
4139
+ getClassList(elm).add(token);
4022
4140
  }
4023
4141
  }
4024
4142
 
4025
4143
  function updateNodeHook(oldVnode, vnode) {
4026
4144
  const {
4027
4145
  elm,
4028
- text,
4029
- owner: {
4030
- renderer
4031
- }
4146
+ text
4032
4147
  } = vnode;
4033
4148
 
4034
4149
  if (oldVnode.text !== text) {
@@ -4036,7 +4151,7 @@ function updateNodeHook(oldVnode, vnode) {
4036
4151
  unlockDomMutation();
4037
4152
  }
4038
4153
 
4039
- renderer.setText(elm, text);
4154
+ setText(elm, text);
4040
4155
 
4041
4156
  if (process.env.NODE_ENV !== 'production') {
4042
4157
  lockDomMutation();
@@ -4044,30 +4159,22 @@ function updateNodeHook(oldVnode, vnode) {
4044
4159
  }
4045
4160
  }
4046
4161
  function insertNodeHook(vnode, parentNode, referenceNode) {
4047
- const {
4048
- renderer
4049
- } = vnode.owner;
4050
-
4051
4162
  if (process.env.NODE_ENV !== 'production') {
4052
4163
  unlockDomMutation();
4053
4164
  }
4054
4165
 
4055
- renderer.insert(vnode.elm, parentNode, referenceNode);
4166
+ insert(vnode.elm, parentNode, referenceNode);
4056
4167
 
4057
4168
  if (process.env.NODE_ENV !== 'production') {
4058
4169
  lockDomMutation();
4059
4170
  }
4060
4171
  }
4061
4172
  function removeNodeHook(vnode, parentNode) {
4062
- const {
4063
- renderer
4064
- } = vnode.owner;
4065
-
4066
4173
  if (process.env.NODE_ENV !== 'production') {
4067
4174
  unlockDomMutation();
4068
4175
  }
4069
4176
 
4070
- renderer.remove(vnode.elm, parentNode);
4177
+ remove(vnode.elm, parentNode);
4071
4178
 
4072
4179
  if (process.env.NODE_ENV !== 'production') {
4073
4180
  lockDomMutation();
@@ -4226,8 +4333,7 @@ function createViewModelHook(elm, vnode) {
4226
4333
  createVM(elm, def, {
4227
4334
  mode,
4228
4335
  owner,
4229
- tagName: sel,
4230
- renderer: owner.renderer
4336
+ tagName: sel
4231
4337
  });
4232
4338
 
4233
4339
  if (process.env.NODE_ENV !== 'production') {
@@ -4271,16 +4377,13 @@ function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4271
4377
  const {
4272
4378
  data: {
4273
4379
  attrs = {}
4274
- },
4275
- owner: {
4276
- renderer
4277
4380
  }
4278
4381
  } = vnode;
4279
4382
  let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
4280
4383
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
4281
4384
 
4282
4385
  for (const [attrName, attrValue] of Object.entries(attrs)) {
4283
- const elmAttrValue = renderer.getAttribute(elm, attrName);
4386
+ const elmAttrValue = getAttribute(elm, attrName);
4284
4387
 
4285
4388
  if (String(attrValue) !== elmAttrValue) {
4286
4389
  logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
@@ -4296,9 +4399,6 @@ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4296
4399
  data: {
4297
4400
  className,
4298
4401
  classMap
4299
- },
4300
- owner: {
4301
- renderer
4302
4402
  }
4303
4403
  } = vnode;
4304
4404
  let nodesAreCompatible = true;
@@ -4310,7 +4410,7 @@ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4310
4410
  vnodeClassName = className;
4311
4411
  } else if (!shared.isUndefined(classMap)) {
4312
4412
  // classMap is used when class is set to static value.
4313
- const classList = renderer.getClassList(elm);
4413
+ const classList = getClassList(elm);
4314
4414
  let computedClassName = ''; // all classes from the vnode should be in the element.classList
4315
4415
 
4316
4416
  for (const name in classMap) {
@@ -4340,12 +4440,9 @@ function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
4340
4440
  data: {
4341
4441
  style,
4342
4442
  styleDecls
4343
- },
4344
- owner: {
4345
- renderer
4346
4443
  }
4347
4444
  } = vnode;
4348
- const elmStyle = renderer.getAttribute(elm, 'style') || '';
4445
+ const elmStyle = getAttribute(elm, 'style') || '';
4349
4446
  let vnodeStyle;
4350
4447
  let nodesAreCompatible = true;
4351
4448
 
@@ -4477,12 +4574,12 @@ function hasDynamicChildren(children) {
4477
4574
  * SPDX-License-Identifier: MIT
4478
4575
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4479
4576
  */
4480
- function getUpgradableConstructor(tagName, renderer) {
4577
+ function getUpgradableConstructor(tagName) {
4481
4578
  // Should never get a tag with upper case letter at this point, the compiler should
4482
4579
  // produce only tags with lowercase letters
4483
4580
  // But, for backwards compatibility, we will lower case the tagName
4484
4581
  tagName = tagName.toLowerCase();
4485
- let CE = renderer.getCustomElement(tagName);
4582
+ let CE = getCustomElement(tagName);
4486
4583
 
4487
4584
  if (!shared.isUndefined(CE)) {
4488
4585
  return CE;
@@ -4493,7 +4590,7 @@ function getUpgradableConstructor(tagName, renderer) {
4493
4590
  */
4494
4591
 
4495
4592
 
4496
- CE = class LWCUpgradableElement extends renderer.HTMLElement {
4593
+ CE = class LWCUpgradableElement extends HTMLElementExported {
4497
4594
  constructor(upgradeCallback) {
4498
4595
  super();
4499
4596
 
@@ -4503,7 +4600,7 @@ function getUpgradableConstructor(tagName, renderer) {
4503
4600
  }
4504
4601
 
4505
4602
  };
4506
- renderer.defineCustomElement(tagName, CE);
4603
+ defineCustomElement(tagName, CE);
4507
4604
  return CE;
4508
4605
  }
4509
4606
 
@@ -4520,10 +4617,7 @@ const TextHook = {
4520
4617
  const {
4521
4618
  owner
4522
4619
  } = vnode;
4523
- const {
4524
- renderer
4525
- } = owner;
4526
- const elm = renderer.createText(vnode.text);
4620
+ const elm = createText(vnode.text);
4527
4621
  linkNodeToShadow(elm, owner);
4528
4622
  vnode.elm = elm;
4529
4623
  },
@@ -4557,10 +4651,7 @@ const CommentHook = {
4557
4651
  owner,
4558
4652
  text
4559
4653
  } = vnode;
4560
- const {
4561
- renderer
4562
- } = owner;
4563
- const elm = renderer.createComment(text);
4654
+ const elm = createComment(text);
4564
4655
  linkNodeToShadow(elm, owner);
4565
4656
  vnode.elm = elm;
4566
4657
  },
@@ -4602,11 +4693,8 @@ const ElementHook = {
4602
4693
  svg
4603
4694
  }
4604
4695
  } = vnode;
4605
- const {
4606
- renderer
4607
- } = owner;
4608
4696
  const namespace = shared.isTrue(svg) ? SVG_NAMESPACE : undefined;
4609
- const elm = renderer.createElement(sel, namespace);
4697
+ const elm = createElement(sel, namespace);
4610
4698
  linkNodeToShadow(elm, owner);
4611
4699
  fallbackElmHook(elm, vnode);
4612
4700
  vnode.elm = elm;
@@ -4666,10 +4754,7 @@ const CustomElementHook = {
4666
4754
  sel,
4667
4755
  owner
4668
4756
  } = vnode;
4669
- const {
4670
- renderer
4671
- } = owner;
4672
- const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
4757
+ const UpgradableConstructor = getUpgradableConstructor(sel);
4673
4758
  /**
4674
4759
  * Note: if the upgradable constructor does not expect, or throw when we new it
4675
4760
  * with a callback as the first argument, we could implement a more advanced
@@ -4762,8 +4847,7 @@ const CustomElementHook = {
4762
4847
  createVM(elm, def, {
4763
4848
  mode,
4764
4849
  owner,
4765
- tagName: sel,
4766
- renderer: owner.renderer
4850
+ tagName: sel
4767
4851
  });
4768
4852
  vnode.elm = elm;
4769
4853
  const vm = getAssociatedVM(elm);
@@ -4792,12 +4876,11 @@ const CustomElementHook = {
4792
4876
 
4793
4877
  function linkNodeToShadow(elm, owner) {
4794
4878
  const {
4795
- renderer,
4796
4879
  renderMode,
4797
4880
  shadowMode
4798
4881
  } = owner; // TODO [#1164]: this should eventually be done by the polyfill directly
4799
4882
 
4800
- if (renderer.isSyntheticShadowDefined) {
4883
+ if (isSyntheticShadowDefined) {
4801
4884
  if (shadowMode === 1
4802
4885
  /* Synthetic */
4803
4886
  || renderMode === 0
@@ -5329,7 +5412,6 @@ function updateStylesheetToken(vm, template) {
5329
5412
  const {
5330
5413
  elm,
5331
5414
  context,
5332
- renderer,
5333
5415
  renderMode,
5334
5416
  shadowMode
5335
5417
  } = vm;
@@ -5356,11 +5438,11 @@ function updateStylesheetToken(vm, template) {
5356
5438
  } = context;
5357
5439
 
5358
5440
  if (oldHasTokenInClass) {
5359
- renderer.getClassList(elm).remove(makeHostToken(oldToken));
5441
+ getClassList(elm).remove(makeHostToken(oldToken));
5360
5442
  }
5361
5443
 
5362
5444
  if (oldHasTokenInAttribute) {
5363
- renderer.removeAttribute(elm, makeHostToken(oldToken));
5445
+ removeAttribute(elm, makeHostToken(oldToken));
5364
5446
  } // Apply the new template styling token to the host element, if the new template has any
5365
5447
  // associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
5366
5448
 
@@ -5372,12 +5454,12 @@ function updateStylesheetToken(vm, template) {
5372
5454
 
5373
5455
  if (!shared.isUndefined(newToken)) {
5374
5456
  if (hasScopedStyles) {
5375
- renderer.getClassList(elm).add(makeHostToken(newToken));
5457
+ getClassList(elm).add(makeHostToken(newToken));
5376
5458
  newHasTokenInClass = true;
5377
5459
  }
5378
5460
 
5379
5461
  if (isSyntheticShadow) {
5380
- renderer.setAttribute(elm, makeHostToken(newToken), '');
5462
+ setAttribute(elm, makeHostToken(newToken), '');
5381
5463
  newHasTokenInAttribute = true;
5382
5464
  }
5383
5465
  } // Update the styling tokens present on the context object.
@@ -5497,7 +5579,6 @@ function getNearestNativeShadowComponent(vm) {
5497
5579
 
5498
5580
  function createStylesheet(vm, stylesheets) {
5499
5581
  const {
5500
- renderer,
5501
5582
  renderMode,
5502
5583
  shadowMode
5503
5584
  } = vm;
@@ -5508,9 +5589,9 @@ function createStylesheet(vm, stylesheets) {
5508
5589
  /* Synthetic */
5509
5590
  ) {
5510
5591
  for (let i = 0; i < stylesheets.length; i++) {
5511
- renderer.insertGlobalStylesheet(stylesheets[i]);
5592
+ insertGlobalStylesheet(stylesheets[i]);
5512
5593
  }
5513
- } else if (renderer.ssr || renderer.isHydrating()) {
5594
+ } else if (ssr || isHydrating()) {
5514
5595
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
5515
5596
  // This works in the client, because the stylesheets are created, and cached in the VM
5516
5597
  // the first time the VM renders.
@@ -5524,10 +5605,10 @@ function createStylesheet(vm, stylesheets) {
5524
5605
 
5525
5606
  for (let i = 0; i < stylesheets.length; i++) {
5526
5607
  if (isGlobal) {
5527
- renderer.insertGlobalStylesheet(stylesheets[i]);
5608
+ insertGlobalStylesheet(stylesheets[i]);
5528
5609
  } else {
5529
5610
  // local level
5530
- renderer.insertStylesheet(stylesheets[i], root.cmpRoot);
5611
+ insertStylesheet(stylesheets[i], root.cmpRoot);
5531
5612
  }
5532
5613
  }
5533
5614
  }
@@ -6188,7 +6269,6 @@ function createVM(elm, def, options) {
6188
6269
  const {
6189
6270
  mode,
6190
6271
  owner,
6191
- renderer,
6192
6272
  tagName
6193
6273
  } = options;
6194
6274
  const vm = {
@@ -6203,7 +6283,6 @@ function createVM(elm, def, options) {
6203
6283
  tagName,
6204
6284
  mode,
6205
6285
  owner,
6206
- renderer,
6207
6286
  children: EmptyArray,
6208
6287
  aChildren: EmptyArray,
6209
6288
  velements: EmptyArray,
@@ -6258,13 +6337,8 @@ function createVM(elm, def, options) {
6258
6337
 
6259
6338
  function computeShadowMode(vm) {
6260
6339
  const {
6261
- def,
6262
- renderer
6340
+ def
6263
6341
  } = vm;
6264
- const {
6265
- isNativeShadowDefined,
6266
- isSyntheticShadowDefined
6267
- } = renderer;
6268
6342
  let shadowMode;
6269
6343
 
6270
6344
  if (isSyntheticShadowDefined) {
@@ -6414,13 +6488,12 @@ function patchShadowRoot(vm, newCh) {
6414
6488
 
6415
6489
  function runRenderedCallback(vm) {
6416
6490
  const {
6417
- renderer,
6418
6491
  def: {
6419
6492
  renderedCallback
6420
6493
  }
6421
6494
  } = vm;
6422
6495
 
6423
- if (shared.isTrue(renderer.ssr)) {
6496
+ if (shared.isTrue(ssr)) {
6424
6497
  return;
6425
6498
  }
6426
6499
 
@@ -6646,8 +6719,7 @@ function recursivelyDisconnectChildren(vnodes) {
6646
6719
 
6647
6720
  function resetComponentRoot(vm) {
6648
6721
  const {
6649
- children,
6650
- renderer
6722
+ children
6651
6723
  } = vm;
6652
6724
  const rootNode = getRenderRoot(vm);
6653
6725
 
@@ -6655,7 +6727,7 @@ function resetComponentRoot(vm) {
6655
6727
  const child = children[i];
6656
6728
 
6657
6729
  if (!shared.isNull(child) && !shared.isUndefined(child.elm)) {
6658
- renderer.remove(child.elm, rootNode);
6730
+ remove(child.elm, rootNode);
6659
6731
  }
6660
6732
  }
6661
6733
 
@@ -6664,7 +6736,7 @@ function resetComponentRoot(vm) {
6664
6736
  vm.velements = EmptyArray;
6665
6737
  }
6666
6738
  function scheduleRehydration(vm) {
6667
- if (shared.isTrue(vm.renderer.ssr) || shared.isTrue(vm.isScheduled)) {
6739
+ if (shared.isTrue(ssr) || shared.isTrue(vm.isScheduled)) {
6668
6740
  return;
6669
6741
  }
6670
6742
 
@@ -6904,7 +6976,6 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
6904
6976
 
6905
6977
  const {
6906
6978
  elm,
6907
- renderer,
6908
6979
  context: {
6909
6980
  wiredConnecting,
6910
6981
  wiredDisconnecting
@@ -6931,7 +7002,7 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
6931
7002
  }
6932
7003
 
6933
7004
  });
6934
- renderer.dispatchEvent(elm, contextRegistrationEvent);
7005
+ dispatchEvent(elm, contextRegistrationEvent);
6935
7006
  });
6936
7007
  }
6937
7008
 
@@ -7214,11 +7285,51 @@ exports.registerComponent = registerComponent;
7214
7285
  exports.registerDecorators = registerDecorators;
7215
7286
  exports.registerTemplate = registerTemplate;
7216
7287
  exports.sanitizeAttribute = sanitizeAttribute;
7288
+ exports.setAddEventListener = setAddEventListener;
7289
+ exports.setAssertInstanceOfHTMLElement = setAssertInstanceOfHTMLElement;
7290
+ exports.setAttachShadow = setAttachShadow;
7291
+ exports.setCreateComment = setCreateComment;
7292
+ exports.setCreateElement = setCreateElement;
7293
+ exports.setCreateText = setCreateText;
7294
+ exports.setDefineCustomElement = setDefineCustomElement;
7295
+ exports.setDispatchEvent = setDispatchEvent;
7296
+ exports.setGetAttribute = setGetAttribute;
7297
+ exports.setGetBoundingClientRect = setGetBoundingClientRect;
7298
+ exports.setGetChildNodes = setGetChildNodes;
7299
+ exports.setGetChildren = setGetChildren;
7300
+ exports.setGetClassList = setGetClassList;
7301
+ exports.setGetCustomElement = setGetCustomElement;
7302
+ exports.setGetElementsByClassName = setGetElementsByClassName;
7303
+ exports.setGetElementsByTagName = setGetElementsByTagName;
7304
+ exports.setGetFirstChild = setGetFirstChild;
7305
+ exports.setGetFirstElementChild = setGetFirstElementChild;
7306
+ exports.setGetLastChild = setGetLastChild;
7307
+ exports.setGetLastElementChild = setGetLastElementChild;
7308
+ exports.setGetProperty = setGetProperty;
7309
+ exports.setHTMLElement = setHTMLElement;
7217
7310
  exports.setHooks = setHooks;
7311
+ exports.setInsert = setInsert;
7312
+ exports.setInsertGlobalStylesheet = setInsertGlobalStylesheet;
7313
+ exports.setInsertStylesheet = setInsertStylesheet;
7314
+ exports.setIsConnected = setIsConnected;
7315
+ exports.setIsHydrating = setIsHydrating;
7316
+ exports.setIsNativeShadowDefined = setIsNativeShadowDefined;
7317
+ exports.setIsSyntheticShadowDefined = setIsSyntheticShadowDefined;
7318
+ exports.setNextSibling = setNextSibling;
7319
+ exports.setQuerySelector = setQuerySelector;
7320
+ exports.setQuerySelectorAll = setQuerySelectorAll;
7321
+ exports.setRemove = setRemove;
7322
+ exports.setRemoveAttribute = setRemoveAttribute;
7323
+ exports.setRemoveEventListener = setRemoveEventListener;
7324
+ exports.setSetAttribute = setSetAttribute;
7325
+ exports.setSetCSSStyleProperty = setSetCSSStyleProperty;
7326
+ exports.setSetProperty = setSetProperty;
7327
+ exports.setSetText = setSetText;
7328
+ exports.setSsr = setSsr;
7218
7329
  exports.swapComponent = swapComponent;
7219
7330
  exports.swapStyle = swapStyle;
7220
7331
  exports.swapTemplate = swapTemplate;
7221
7332
  exports.track = track;
7222
7333
  exports.unwrap = unwrap;
7223
7334
  exports.wire = wire;
7224
- /* version: 2.6.2 */
7335
+ /* version: 2.6.3 */