@lwrjs/everywhere 0.12.0-alpha.3 → 0.12.0-alpha.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. package/README.md +2 -0
  2. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/0f487d9679581c125b53bfa6b582cfcc/config.js +11 -0
  3. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_12_0-alpha_5/s/8bce578258518655194bd71d1d72aad5/@lwrjs_app-service_amd-bootstrap_module_amd.js +14 -0
  4. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/{5_2_1/s/ccc2929f679182183c24024e0efea4c0 → 6_0_0/s/6e7ff236fd6011fdc06fb33b61261493}/lwc.js +193 -146
  5. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_12_0-alpha_3 → 0_12_0-alpha_5}/s/cb931ebef2b89dcf8ab51456e3a68864/lwr_everywhereAmd.js +3 -3
  6. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/{0_12_0-alpha_3 → 0_12_0-alpha_5}/s/f30361ad8ff7af505bf4d465c8499181/lwr_init.js +21 -21
  7. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_12_0-alpha_3/s/820b8b3d56c7a1873095e47ba8f33509 → 0_12_0-alpha_5/s/86f0bfd98af9ec4a250fa009da12c281}/lwr_loader.js +3 -3
  8. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_12_0-alpha_3 → 0_12_0-alpha_5}/s/274c8343f810353bbad085a79709395f/lwr_metrics.js +1 -1
  9. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/preInit/v/{0_12_0-alpha_3 → 0_12_0-alpha_5}/s/f3a204ef43fb3057d910f80d7e9f9ba7/lwr_preInit.js +1 -1
  10. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/{0_12_0-alpha_3 → 0_12_0-alpha_5}/s/a152b8d35f12ca1b5147c5cd1ee155fb/lwr_profiler.js +1 -1
  11. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/{0_12_0-alpha_3 → 0_12_0-alpha_5}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +1 -1
  12. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_12_0-alpha_3 → 0_12_0-alpha_5}/lwr-error-shim.js +1 -1
  13. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/{0_12_0-alpha_3 → 0_12_0-alpha_5}/lwr-loader-shim.bundle.js +6 -6
  14. package/build/assets/amd/lwr-everywhere-debug.js +8 -8
  15. package/build/assets/amd/lwr-everywhere-min.js +2 -2
  16. package/build/assets/amd/lwr-everywhere.js +8 -8
  17. package/build/assets/core/lwr-everywhere-debug.js +4 -4
  18. package/build/assets/core/lwr-everywhere.js +4 -4
  19. package/build/assets/esm/lwr-everywhere-debug.js +1 -1
  20. package/build/assets/esm/lwr-everywhere-min.js +1 -1
  21. package/build/assets/esm/lwr-everywhere.js +1 -1
  22. package/package.json +8 -8
  23. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/22ba4f092a0ad5d5fd43174af54ec9bd/config.js +0 -11
  24. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_12_0-alpha_3/s/8bce578258518655194bd71d1d72aad5/@lwrjs_app-service_amd-bootstrap_module_amd.js +0 -14
@@ -1,4 +1,4 @@
1
- LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1
+ LWR.define('lwc/v/6_0_0', ['exports'], (function (exports) { 'use strict';
2
2
 
3
3
  /**
4
4
  * Copyright (C) 2023 salesforce.com, inc.
@@ -183,6 +183,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
183
183
  case 4 /* APIFeature.SKIP_UNNECESSARY_REGISTER_DECORATORS */:
184
184
  case 5 /* APIFeature.USE_COMMENTS_FOR_FRAGMENT_BOOKENDS */:
185
185
  return apiVersion >= 60 /* APIVersion.V60_248_SPRING_24 */;
186
+ case 6 /* APIFeature.USE_LIGHT_DOM_SLOT_FORWARDING */:
187
+ case 7 /* APIFeature.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE */:
188
+ return apiVersion >= 61 /* APIVersion.V61_250_SUMMER_24 */;
186
189
  }
187
190
  }
188
191
 
@@ -316,9 +319,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
316
319
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
317
320
  */
318
321
  // Increment whenever the LWC template compiler changes
319
- const LWC_VERSION = "5.2.1";
322
+ const LWC_VERSION = "6.0.0";
320
323
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
321
- /** version: 5.2.1 */
324
+ /** version: 6.0.0 */
322
325
 
323
326
  /**
324
327
  * Copyright (C) 2023 salesforce.com, inc.
@@ -336,7 +339,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
336
339
  PLACEHOLDER_TEST_FLAG: null,
337
340
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
338
341
  ENABLE_MIXED_SHADOW_MODE: null,
339
- ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
342
+ DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
340
343
  ENABLE_WIRE_SYNC_EMIT: null,
341
344
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
342
345
  ENABLE_FROZEN_TEMPLATE: null,
@@ -398,7 +401,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
398
401
  setFeatureFlag(name, value);
399
402
  }
400
403
  }
401
- /** version: 5.2.1 */
404
+ /** version: 6.0.0 */
402
405
 
403
406
  /**
404
407
  * Copyright (C) 2023 salesforce.com, inc.
@@ -733,6 +736,14 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
733
736
  }
734
737
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
735
738
  }
739
+ function shouldUseNativeCustomElementLifecycle(ctor) {
740
+ if (lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
741
+ // temporary "kill switch"
742
+ return false;
743
+ }
744
+ const apiVersion = getComponentAPIVersion(ctor);
745
+ return isAPIFeatureEnabled(7 /* APIFeature.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE */, apiVersion);
746
+ }
736
747
  // Borrowed from Vue template compiler.
737
748
  // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
738
749
  const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
@@ -798,53 +809,52 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
798
809
  const instrumentInstance = (_b = _globalThis.__lwc_instrument_cmp_instance) !== null && _b !== void 0 ? _b : noop;
799
810
 
800
811
  /*
801
- * Copyright (c) 2023, salesforce.com, inc.
812
+ * Copyright (c) 2018, salesforce.com, inc.
802
813
  * All rights reserved.
803
814
  * SPDX-License-Identifier: MIT
804
815
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
805
816
  */
806
- // Apply ARIA string reflection behavior to a prototype.
807
- // This is deliberately kept separate from @lwc/aria-reflection. @lwc/aria-reflection is a global polyfill that is
808
- // needed for backwards compatibility in LEX, whereas `applyAriaReflection` is designed to only apply to our own
809
- // LightningElement/BaseBridgeElement prototypes.
810
- function applyAriaReflection(prototype) {
811
- for (const propName of keys(AriaPropNameToAttrNameMap)) {
812
- const attrName = AriaPropNameToAttrNameMap[propName];
813
- if (isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName))) {
814
- // Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
815
- // from Element.prototype, because these methods are overridden in LightningElement.
816
- defineProperty(prototype, propName, {
817
- get() {
818
- return this.getAttribute(attrName);
819
- },
820
- set(newValue) {
821
- // TODO [#3284]: there is disagreement between browsers and the spec on how to treat undefined
822
- // Our historical behavior is to only treat null as removing the attribute
823
- // See also https://github.com/w3c/aria/issues/1858
824
- if (isNull(newValue)) {
825
- this.removeAttribute(attrName);
826
- } else {
827
- this.setAttribute(attrName, newValue);
828
- }
829
- },
830
- // configurable and enumerable to allow it to be overridden – this mimics Safari's/Chrome's behavior
831
- configurable: true,
832
- enumerable: true
833
- });
834
- }
835
- }
836
- }
817
+ // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
818
+ // to inject at runtime.
819
+ const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
820
+ const HTMLElementPrototype = HTMLElementConstructor.prototype;
837
821
 
838
822
  /*
839
- * Copyright (c) 2018, salesforce.com, inc.
823
+ * Copyright (c) 2023, salesforce.com, inc.
840
824
  * All rights reserved.
841
825
  * SPDX-License-Identifier: MIT
842
826
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
843
827
  */
844
- // This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
845
- // to inject at runtime.
846
- const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
847
- const HTMLElementPrototype = HTMLElementConstructor.prototype;
828
+ // Apply ARIA string reflection behavior to a prototype.
829
+ // This is deliberately kept separate from @lwc/aria-reflection. @lwc/aria-reflection is a global polyfill that is
830
+ // needed for backwards compatibility in LEX, whereas this is designed to only apply to our own
831
+ // LightningElement/BaseBridgeElement prototypes.
832
+ // Note we only need to handle ARIA reflections that aren't already in Element.prototype
833
+ const ariaReflectionPolyfillDescriptors = create(null);
834
+ for (const [propName, attrName] of entries(AriaPropNameToAttrNameMap)) {
835
+ if (isUndefined$1(getPropertyDescriptor(HTMLElementPrototype, propName))) {
836
+ // Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
837
+ // from Element.prototype, because these methods are overridden in LightningElement.
838
+ ariaReflectionPolyfillDescriptors[propName] = {
839
+ get() {
840
+ return this.getAttribute(attrName);
841
+ },
842
+ set(newValue) {
843
+ // TODO [#3284]: there is disagreement between browsers and the spec on how to treat undefined
844
+ // Our historical behavior is to only treat null as removing the attribute
845
+ // See also https://github.com/w3c/aria/issues/1858
846
+ if (isNull(newValue)) {
847
+ this.removeAttribute(attrName);
848
+ } else {
849
+ this.setAttribute(attrName, newValue);
850
+ }
851
+ },
852
+ // configurable and enumerable to allow it to be overridden – this mimics Safari's/Chrome's behavior
853
+ configurable: true,
854
+ enumerable: true
855
+ };
856
+ }
857
+ }
848
858
 
849
859
  /*
850
860
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1094,28 +1104,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1094
1104
  })
1095
1105
  };
1096
1106
  }
1097
- function getLightningElementPrototypeRestrictionsDescriptors(proto) {
1098
- assertNotProd(); // this method should never leak to prod
1099
- const originalDispatchEvent = proto.dispatchEvent;
1100
- return {
1101
- dispatchEvent: generateDataDescriptor({
1102
- value(event) {
1103
- const vm = getAssociatedVM(this);
1104
- if (!isNull(event) && isObject(event)) {
1105
- const {
1106
- type
1107
- } = event;
1108
- if (!/^[a-z][a-z0-9_]*$/.test(type)) {
1109
- logError(`Invalid event type "${type}" dispatched in element ${getComponentTag(vm)}.` + ` Event name must start with a lowercase letter and followed only lowercase` + ` letters, numbers, and underscores`, vm);
1110
- }
1111
- }
1112
- // Typescript does not like it when you treat the `arguments` object as an array
1113
- // @ts-ignore type-mismatch
1114
- return originalDispatchEvent.apply(this, arguments);
1115
- }
1116
- })
1117
- };
1118
- }
1119
1107
  // This routine will prevent access to certain properties on a shadow root instance to guarantee
1120
1108
  // that all components will work fine in IE11 and other browsers without shadow dom support.
1121
1109
  function patchShadowRootWithRestrictions(sr) {
@@ -1126,9 +1114,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1126
1114
  const elmProto = getPrototypeOf$1(elm);
1127
1115
  setPrototypeOf(elm, create(elmProto, restrictionsDescriptors));
1128
1116
  }
1129
- function patchLightningElementPrototypeWithRestrictions(proto) {
1130
- defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1131
- }
1132
1117
  function updateComponentValue(vm, key, newValue) {
1133
1118
  const {
1134
1119
  cmpFields
@@ -1505,7 +1490,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1505
1490
  valueMutated(originalTarget, key);
1506
1491
  return true;
1507
1492
  }
1508
- /*LWC compiler v5.2.1*/
1493
+ /*LWC compiler v6.0.0*/
1509
1494
  }
1510
1495
  const getterMap = new WeakMap();
1511
1496
  const setterMap = new WeakMap();
@@ -1598,7 +1583,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
1598
1583
  /* istanbul ignore next */
1599
1584
  return false;
1600
1585
  }
1601
- /*LWC compiler v5.2.1*/
1586
+ /*LWC compiler v6.0.0*/
1602
1587
  }
1603
1588
  function extract(objectOrArray) {
1604
1589
  if (isArray(objectOrArray)) {
@@ -2462,11 +2447,17 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2462
2447
  for (const propName in HTMLElementOriginalDescriptors) {
2463
2448
  lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
2464
2449
  }
2465
- defineProperties(LightningElement.prototype, lightningBasedDescriptors);
2466
2450
  // Apply ARIA reflection to LightningElement.prototype, on both the browser and server.
2467
2451
  // This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
2468
2452
  // Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
2469
- applyAriaReflection(LightningElement.prototype);
2453
+ {
2454
+ // In the browser, we use createBridgeToElementDescriptor, so we can get the normal reactivity lifecycle for
2455
+ // aria* properties
2456
+ for (const [propName, descriptor] of entries(ariaReflectionPolyfillDescriptors)) {
2457
+ lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, descriptor);
2458
+ }
2459
+ }
2460
+ defineProperties(LightningElement.prototype, lightningBasedDescriptors);
2470
2461
  defineProperty(LightningElement, 'CustomElementConstructor', {
2471
2462
  get() {
2472
2463
  // If required, a runtime-specific implementation must be defined.
@@ -2474,9 +2465,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
2474
2465
  },
2475
2466
  configurable: true
2476
2467
  });
2477
- if (process.env.NODE_ENV !== 'production') {
2478
- patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
2479
- }
2480
2468
  function createObservedFieldPropertyDescriptor(key) {
2481
2469
  return {
2482
2470
  get() {
@@ -3347,7 +3335,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3347
3335
  }
3348
3336
  function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observedFields, proto, hasCustomSuperClass) {
3349
3337
  const HTMLBridgeElement = class extends SuperClass {
3350
- /*LWC compiler v5.2.1*/
3338
+ /*LWC compiler v6.0.0*/
3351
3339
  };
3352
3340
  // generating the hash table for attributes to avoid duplicate fields and facilitate validation
3353
3341
  // and false positives in case of inheritance.
@@ -3372,7 +3360,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3372
3360
  // and can break tooling that expects it to be iterable or defined, e.g. Jest:
3373
3361
  // https://github.com/jestjs/jest/blob/b4c9587/packages/pretty-format/src/plugins/DOMElement.ts#L95
3374
3362
  // It also doesn't make sense to override e.g. "constructor".
3375
- .filter(propName => !(propName in HTMLElementPrototype)));
3363
+ .filter(propName => !(propName in HTMLElementPrototype) && !(propName in ariaReflectionPolyfillDescriptors)));
3376
3364
  for (const propName of nonPublicPropertiesToWarnOn) {
3377
3365
  if (ArrayIndexOf.call(publicProperties, propName) === -1) {
3378
3366
  descriptors[propName] = createAccessorThatWarns(propName);
@@ -3442,21 +3430,19 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
3442
3430
  defineProperties(HTMLBridgeElement.prototype, descriptors);
3443
3431
  return HTMLBridgeElement;
3444
3432
  }
3445
- const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), [], [], null, false);
3446
- {
3447
- // This ARIA reflection only really makes sense in the browser. On the server, there is no `renderedCallback()`,
3448
- // so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't need to expose
3449
- // ARIA props outside the LightningElement
3450
- //
3451
- // Apply ARIA reflection to HTMLBridgeElement.prototype. This allows `elm.aria*` property accessors to work from
3452
- // outside a component, and to reflect `aria-*` attrs. This is especially important because the template compiler
3453
- // compiles aria-* attrs on components to aria* props.
3454
- // Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
3455
- //
3456
- // Also note that we apply this to BaseBridgeElement.prototype to avoid excessively redefining property
3457
- // accessors inside the HTMLBridgeElementFactory.
3458
- applyAriaReflection(BaseBridgeElement.prototype);
3459
- }
3433
+ // We do some special handling of non-standard ARIA props like ariaLabelledBy as well as props without (as of this
3434
+ // writing) broad cross-browser support like ariaBrailleLabel. This is so the reflection works correctly and preserves
3435
+ // backwards compatibility with the previous global polyfill approach.
3436
+ //
3437
+ // The goal here is to expose `elm.aria*` property accessors to work from outside a component, and to reflect `aria-*`
3438
+ // attrs. This is especially important because the template compiler compiles aria-* attrs on components to aria* props.
3439
+ // Note this works regardless of whether the global ARIA reflection polyfill is applied or not.
3440
+ //
3441
+ // Also note this ARIA reflection only really makes sense in the browser. On the server, there is no
3442
+ // `renderedCallback()`, so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't
3443
+ // need to expose ARIA props outside the LightningElement
3444
+ const basePublicProperties = [...getOwnPropertyNames$1(HTMLElementOriginalDescriptors), ...getOwnPropertyNames$1(ariaReflectionPolyfillDescriptors)];
3445
+ const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, basePublicProperties, [], [], null, false);
3460
3446
  freeze(BaseBridgeElement);
3461
3447
  seal(BaseBridgeElement.prototype);
3462
3448
 
@@ -4223,6 +4209,9 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4223
4209
  function isVScopedSlotFragment(vnode) {
4224
4210
  return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
4225
4211
  }
4212
+ function isVStatic(vnode) {
4213
+ return vnode.type === 4 /* VNodeType.Static */;
4214
+ }
4226
4215
 
4227
4216
  /*
4228
4217
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4276,6 +4265,26 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4276
4265
  }
4277
4266
  }
4278
4267
  }
4268
+ function patchSlotAssignment(oldVnode, vnode, renderer) {
4269
+ const {
4270
+ slotAssignment
4271
+ } = vnode;
4272
+ if ((oldVnode === null || oldVnode === void 0 ? void 0 : oldVnode.slotAssignment) === slotAssignment) {
4273
+ return;
4274
+ }
4275
+ const {
4276
+ elm
4277
+ } = vnode;
4278
+ const {
4279
+ setAttribute,
4280
+ removeAttribute
4281
+ } = renderer;
4282
+ if (isUndefined$1(slotAssignment) || isNull(slotAssignment)) {
4283
+ removeAttribute(elm, 'slot');
4284
+ } else {
4285
+ setAttribute(elm, 'slot', slotAssignment);
4286
+ }
4287
+ }
4279
4288
 
4280
4289
  /*
4281
4290
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4790,6 +4799,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4790
4799
  }
4791
4800
  function patchStatic(n1, n2, renderer) {
4792
4801
  const elm = n2.elm = n1.elm;
4802
+ // slotAssignments can only apply to the top level element, never to a static part.
4803
+ patchSlotAssignment(n1, n2, renderer);
4793
4804
  // The `refs` object is blown away in every re-render, so we always need to re-apply them
4794
4805
  applyStaticParts(elm, n2, renderer, false);
4795
4806
  }
@@ -4819,13 +4830,16 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4819
4830
  elm[KEY__SHADOW_STATIC] = true;
4820
4831
  }
4821
4832
  }
4833
+ // slotAssignments can only apply to the top level element, never to a static part.
4834
+ patchSlotAssignment(null, vnode, renderer);
4822
4835
  insertNode(elm, parent, anchor, renderer);
4823
4836
  applyStaticParts(elm, vnode, renderer, true);
4824
4837
  }
4825
4838
  function mountCustomElement(vnode, parent, anchor, renderer) {
4826
4839
  const {
4827
4840
  sel,
4828
- owner
4841
+ owner,
4842
+ ctor
4829
4843
  } = vnode;
4830
4844
  const {
4831
4845
  createCustomElement
@@ -4846,7 +4860,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4846
4860
  // compiler may generate tagnames with uppercase letters so - for backwards
4847
4861
  // compatibility, we lower case the tagname here.
4848
4862
  const normalizedTagname = sel.toLowerCase();
4849
- const elm = createCustomElement(normalizedTagname, upgradeCallback);
4863
+ const useNativeLifecycle = shouldUseNativeCustomElementLifecycle(ctor);
4864
+ const elm = createCustomElement(normalizedTagname, upgradeCallback, useNativeLifecycle);
4850
4865
  vnode.elm = elm;
4851
4866
  vnode.vm = vm;
4852
4867
  linkNodeToShadow(elm, owner, renderer);
@@ -4858,7 +4873,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
4858
4873
  insertNode(elm, parent, anchor, renderer);
4859
4874
  if (vm) {
4860
4875
  {
4861
- if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
4876
+ if (!useNativeLifecycle) {
4862
4877
  if (process.env.NODE_ENV !== 'production') {
4863
4878
  // With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
4864
4879
  // noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
@@ -5063,6 +5078,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5063
5078
  patchStyleAttribute(oldVnode, vnode, renderer);
5064
5079
  patchAttributes(oldVnode, vnode, renderer);
5065
5080
  patchProps(oldVnode, vnode, renderer);
5081
+ patchSlotAssignment(oldVnode, vnode, renderer);
5066
5082
  // The `refs` object is blown away in every re-render, so we always need to re-apply them
5067
5083
  applyRefs(vnode, vnode.owner);
5068
5084
  }
@@ -5231,7 +5247,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5231
5247
  return vm;
5232
5248
  }
5233
5249
  function allocateInSlot(vm, children, owner) {
5234
- var _a, _b;
5250
+ var _a;
5235
5251
  const {
5236
5252
  cmpSlots: {
5237
5253
  slotAssignments: oldSlotsMapping
@@ -5245,8 +5261,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5245
5261
  continue;
5246
5262
  }
5247
5263
  let slotName = '';
5248
- if (isVBaseElement(vnode)) {
5249
- slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
5264
+ if (isVBaseElement(vnode) || isVStatic(vnode)) {
5265
+ slotName = (_a = vnode.slotAssignment) !== null && _a !== void 0 ? _a : '';
5250
5266
  } else if (isVScopedSlotFragment(vnode)) {
5251
5267
  slotName = vnode.slotName;
5252
5268
  }
@@ -5502,7 +5518,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5502
5518
  elm: undefined,
5503
5519
  fragment,
5504
5520
  owner,
5505
- parts
5521
+ parts,
5522
+ slotAssignment: undefined
5506
5523
  };
5507
5524
  return vnode;
5508
5525
  }
@@ -5545,7 +5562,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5545
5562
  });
5546
5563
  }
5547
5564
  const {
5548
- key
5565
+ key,
5566
+ slotAssignment
5549
5567
  } = data;
5550
5568
  const vnode = {
5551
5569
  type: 2 /* VNodeType.Element */,
@@ -5554,7 +5572,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5554
5572
  children,
5555
5573
  elm: undefined,
5556
5574
  key,
5557
- owner: vmBeingRendered
5575
+ owner: vmBeingRendered,
5576
+ slotAssignment
5558
5577
  };
5559
5578
  return vnode;
5560
5579
  }
@@ -5579,6 +5598,11 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5579
5598
  assert.isTrue(isObject(data), `s() 2nd argument data must be an object.`);
5580
5599
  assert.isTrue(isArray$1(children), `h() 3rd argument children must be an array.`);
5581
5600
  }
5601
+ const vmBeingRendered = getVMBeingRendered();
5602
+ const {
5603
+ renderMode,
5604
+ apiVersion
5605
+ } = vmBeingRendered;
5582
5606
  if (!isUndefined$1(slotset) && !isUndefined$1(slotset.slotAssignments) && !isUndefined$1(slotset.slotAssignments[slotName]) && slotset.slotAssignments[slotName].length !== 0) {
5583
5607
  const newChildren = [];
5584
5608
  const slotAssignments = slotset.slotAssignments[slotName];
@@ -5598,7 +5622,6 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5598
5622
  }
5599
5623
  // If the passed slot content is factory, evaluate it and add the produced vnodes
5600
5624
  if (assignedNodeIsScopedSlot) {
5601
- const vmBeingRenderedInception = getVMBeingRendered();
5602
5625
  // Evaluate in the scope of the slot content's owner
5603
5626
  // if a slotset is provided, there will always be an owner. The only case where owner is
5604
5627
  // undefined is for root components, but root components cannot accept slotted content
@@ -5613,22 +5636,33 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5613
5636
  ArrayPush$1.call(newChildren, vnode.factory(data.slotData, data.key));
5614
5637
  });
5615
5638
  } finally {
5616
- setVMBeingRendered(vmBeingRenderedInception);
5639
+ setVMBeingRendered(vmBeingRendered);
5617
5640
  }
5618
5641
  } else {
5642
+ // This block is for standard slots (non-scoped slots)
5643
+ let clonedVNode;
5644
+ if (renderMode === 0 /* RenderMode.Light */ && isAPIFeatureEnabled(6 /* APIFeature.USE_LIGHT_DOM_SLOT_FORWARDING */, apiVersion) && (isVBaseElement(vnode) || isVStatic(vnode)) &&
5645
+ // We only need to copy the vnodes when the slot assignment changes, copying every time causes issues with
5646
+ // disconnected/connected callback firing.
5647
+ vnode.slotAssignment !== data.slotAssignment) {
5648
+ // When the light DOM slot assignment (slot attribute) changes we can't use the same reference
5649
+ // to the vnode because the current way the diffing algo works, it will replace the original reference
5650
+ // to the host element with a new one. This means the new element will be mounted and immediately unmounted.
5651
+ // Creating a copy of the vnode to preserve a reference to the previous host element.
5652
+ clonedVNode = Object.assign(Object.assign({}, vnode), {
5653
+ slotAssignment: data.slotAssignment
5654
+ });
5655
+ }
5619
5656
  // If the slot content is standard type, the content is static, no additional
5620
5657
  // processing needed on the vnode
5621
- ArrayPush$1.call(newChildren, vnode);
5658
+ ArrayPush$1.call(newChildren, clonedVNode !== null && clonedVNode !== void 0 ? clonedVNode : vnode);
5622
5659
  }
5623
5660
  }
5624
5661
  }
5625
5662
  children = newChildren;
5626
5663
  }
5627
- const vmBeingRendered = getVMBeingRendered();
5628
5664
  const {
5629
- renderMode,
5630
- shadowMode,
5631
- apiVersion
5665
+ shadowMode
5632
5666
  } = vmBeingRendered;
5633
5667
  if (renderMode === 0 /* RenderMode.Light */) {
5634
5668
  // light DOM slots - backwards-compatible behavior uses flattening, new behavior uses fragments
@@ -5668,7 +5702,8 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5668
5702
  }
5669
5703
  }
5670
5704
  const {
5671
- key
5705
+ key,
5706
+ slotAssignment
5672
5707
  } = data;
5673
5708
  let elm, aChildren, vm;
5674
5709
  const vnode = {
@@ -5678,6 +5713,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
5678
5713
  children,
5679
5714
  elm,
5680
5715
  key,
5716
+ slotAssignment,
5681
5717
  ctor: Ctor,
5682
5718
  owner: vmBeingRendered,
5683
5719
  mode: 'open',
@@ -6560,7 +6596,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6560
6596
  // old vnode.children is removed from the DOM.
6561
6597
  function removeVM(vm) {
6562
6598
  if (process.env.NODE_ENV !== 'production') {
6563
- if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
6599
+ if (!shouldUseNativeCustomElementLifecycle(vm.component.constructor)) {
6564
6600
  // With native lifecycle, we cannot be certain that connectedCallback was called before a component
6565
6601
  // was removed from the VDOM. If the component is disconnected, then connectedCallback will not fire
6566
6602
  // in native mode, although it will fire in synthetic mode due to appendChild triggering it.
@@ -6900,7 +6936,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
6900
6936
  }
6901
6937
  // This test only makes sense in the browser, with synthetic lifecycle, and when reporting is enabled or
6902
6938
  // we're in dev mode. This is to detect a particular issue with synthetic lifecycle.
6903
- if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE && (process.env.NODE_ENV !== 'production' || isReportingEnabled())) {
6939
+ if (!shouldUseNativeCustomElementLifecycle(vm.component.constructor) && (process.env.NODE_ENV !== 'production' || isReportingEnabled())) {
6904
6940
  if (!vm.renderer.isConnected(vm.elm)) {
6905
6941
  if (process.env.NODE_ENV !== 'production') {
6906
6942
  logWarnOnce(`Element <${vm.tagName}> ` + `fired a \`connectedCallback\` and rendered, but was not connected to the DOM. ` + `Please ensure all components are actually connected to the DOM, e.g. using ` + `\`document.body.appendChild(element)\`. This will not be supported in future versions of ` + `LWC and could cause component errors. For details, see: https://sfdc.co/synthetic-lifecycle`);
@@ -8233,7 +8269,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8233
8269
  }
8234
8270
  return getReadOnlyProxy(obj);
8235
8271
  }
8236
- /** version: 5.2.1 */
8272
+ /** version: 6.0.0 */
8237
8273
 
8238
8274
  /*
8239
8275
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8448,17 +8484,17 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8448
8484
  * SPDX-License-Identifier: MIT
8449
8485
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8450
8486
  */
8451
- const cachedConstructors = new Map();
8452
- const elementsUpgradedOutsideLWC = new WeakSet();
8453
- let elementBeingUpgradedByLWC = false;
8454
- const lifecycleCallbacks = lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE ? {
8487
+ const LIFECYCLE_CALLBACKS = {
8455
8488
  connectedCallback: connectRootElement,
8456
8489
  disconnectedCallback: disconnectRootElement,
8457
8490
  formAssociatedCallback: runFormAssociatedCallback,
8458
8491
  formDisabledCallback: runFormDisabledCallback,
8459
8492
  formResetCallback: runFormResetCallback,
8460
8493
  formStateRestoreCallback: runFormStateRestoreCallback
8461
- } : undefined;
8494
+ };
8495
+ const cachedConstructors = new Map();
8496
+ const nativeLifecycleElementsToUpgradedByLWC = new WeakMap();
8497
+ let elementBeingUpgradedByLWC = false;
8462
8498
  // Creates a constructor that is intended to be used directly as a custom element, except that the upgradeCallback is
8463
8499
  // passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
8464
8500
  // Another benefit is that only LWC can create components that actually do anything – if you do
@@ -8467,34 +8503,33 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8467
8503
  const createUpgradableConstructor = () => {
8468
8504
  // TODO [#2972]: this class should expose observedAttributes as necessary
8469
8505
  class UpgradableConstructor extends HTMLElement {
8470
- constructor(upgradeCallback) {
8506
+ constructor(upgradeCallback, useNativeLifecycle) {
8471
8507
  super();
8508
+ if (useNativeLifecycle) {
8509
+ // When in native lifecycle mode, we need to keep track of instances that were created outside LWC
8510
+ // (i.e. not created by `lwc.createElement()`). If the element uses synthetic lifecycle, then we don't
8511
+ // need to track this.
8512
+ nativeLifecycleElementsToUpgradedByLWC.set(this, elementBeingUpgradedByLWC);
8513
+ }
8472
8514
  // If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
8473
- // then elementBeingUpgraded will be false
8515
+ // then elementBeingUpgradedByLWC will be false
8474
8516
  if (elementBeingUpgradedByLWC) {
8475
8517
  upgradeCallback(this);
8476
- } else if (!isUndefined$1(lifecycleCallbacks)) {
8477
- // If this element has any lifecycle callbacks, then we need to keep track of
8478
- // instances that were created outside LWC (i.e. not created by `lwc.createElement()`).
8479
- // If the element has no connected or disconnected callbacks, then we don't need to track this.
8480
- elementsUpgradedOutsideLWC.add(this);
8481
- // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
8482
- // Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
8483
8518
  }
8519
+ // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
8520
+ // Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
8484
8521
  }
8485
- /*LWC compiler v5.2.1*/
8522
+ /*LWC compiler v6.0.0*/
8486
8523
  }
8487
8524
  UpgradableConstructor.formAssociated = true;
8488
- // Do not unnecessarily add a connectedCallback/disconnectedCallback/etc., as it introduces perf overhead
8489
- // See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
8490
- if (!isUndefined$1(lifecycleCallbacks)) {
8491
- for (const [propName, callback] of entries(lifecycleCallbacks)) {
8492
- UpgradableConstructor.prototype[propName] = function () {
8493
- if (!elementsUpgradedOutsideLWC.has(this)) {
8494
- callback(this);
8495
- }
8496
- };
8497
- }
8525
+ for (const [propName, callback] of entries(LIFECYCLE_CALLBACKS)) {
8526
+ UpgradableConstructor.prototype[propName] = function () {
8527
+ // If the element is in the WeakMap (i.e. it's marked as native lifecycle), and if it was upgraded by LWC,
8528
+ // then it can use native lifecycle
8529
+ if (isTrue(nativeLifecycleElementsToUpgradedByLWC.get(this))) {
8530
+ callback(this);
8531
+ }
8532
+ };
8498
8533
  }
8499
8534
  return UpgradableConstructor;
8500
8535
  };
@@ -8510,11 +8545,11 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8510
8545
  }
8511
8546
  return UpgradableConstructor;
8512
8547
  }
8513
- const createCustomElement = (tagName, upgradeCallback) => {
8548
+ const createCustomElement = (tagName, upgradeCallback, useNativeLifecycle) => {
8514
8549
  const UpgradableConstructor = getUpgradableConstructor(tagName);
8515
8550
  elementBeingUpgradedByLWC = true;
8516
8551
  try {
8517
- return new UpgradableConstructor(upgradeCallback);
8552
+ return new UpgradableConstructor(upgradeCallback, useNativeLifecycle);
8518
8553
  } finally {
8519
8554
  elementBeingUpgradedByLWC = false;
8520
8555
  }
@@ -8578,7 +8613,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8578
8613
  function isNull(obj) {
8579
8614
  return obj === null;
8580
8615
  }
8581
- /** version: 5.2.1 */
8616
+ /** version: 6.0.0 */
8582
8617
 
8583
8618
  /*
8584
8619
  * Copyright (c) 2023, salesforce.com, inc.
@@ -8598,7 +8633,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8598
8633
  this.setNewContext = setNewContext;
8599
8634
  this.setDisconnectedCallback = setDisconnectedCallback;
8600
8635
  }
8601
- /*LWC compiler v5.2.1*/
8636
+ /*LWC compiler v6.0.0*/
8602
8637
  }
8603
8638
  function registerContextConsumer(elm, adapterContextToken, subscriptionPayload) {
8604
8639
  dispatchEvent(elm, new WireContextSubscriptionEvent(adapterContextToken, subscriptionPayload));
@@ -8978,7 +9013,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
8978
9013
  attributeChangedCallback(name, oldValue, newValue) {
8979
9014
  attributeChangedCallback.call(this, name, oldValue, newValue);
8980
9015
  }
8981
- /*LWC compiler v5.2.1*/
9016
+ /*LWC compiler v6.0.0*/
8982
9017
  }, _a.observedAttributes = observedAttributes, _a;
8983
9018
  }
8984
9019
 
@@ -9003,7 +9038,13 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9003
9038
  }
9004
9039
  return node; // for convenience
9005
9040
  }
9006
- if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
9041
+ let monkeyPatched = false;
9042
+ function monkeyPatchDomAPIs() {
9043
+ if (monkeyPatched) {
9044
+ // don't double-patch
9045
+ return;
9046
+ }
9047
+ monkeyPatched = true;
9007
9048
  // Monkey patching Node methods to be able to detect the insertions and removal of root elements
9008
9049
  // created via createElement.
9009
9050
  const {
@@ -9059,6 +9100,10 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9059
9100
  // passing `sel` as a camel-case, which makes them invalid custom elements name
9060
9101
  // the following line guarantees that this does not leaks beyond this point.
9061
9102
  const tagName = StringToLowerCase.call(sel);
9103
+ const apiVersion = getComponentAPIVersion(Ctor);
9104
+ const useNativeCustomElementLifecycle =
9105
+ // temporary "kill switch"
9106
+ !lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE && isAPIFeatureEnabled(7 /* APIFeature.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE */, apiVersion);
9062
9107
  // the custom element from the registry is expecting an upgrade callback
9063
9108
  /**
9064
9109
  * Note: if the upgradable constructor does not expect, or throw when we new it
@@ -9072,13 +9117,15 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9072
9117
  mode: options.mode !== 'closed' ? 'open' : 'closed',
9073
9118
  owner: null
9074
9119
  });
9075
- if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
9120
+ if (!useNativeCustomElementLifecycle) {
9121
+ // Monkey-patch on-demand, because if there are no components on the page using an old API
9122
+ // version, then we don't want to monkey patch at all
9123
+ monkeyPatchDomAPIs();
9076
9124
  ConnectingSlot.set(elm, connectRootElement);
9077
9125
  DisconnectingSlot.set(elm, disconnectRootElement);
9078
9126
  }
9079
9127
  };
9080
- const element = createCustomElement(tagName, upgradeCallback);
9081
- return element;
9128
+ return createCustomElement(tagName, upgradeCallback, useNativeCustomElementLifecycle);
9082
9129
  }
9083
9130
 
9084
9131
  /*
@@ -9181,7 +9228,7 @@ LWR.define('lwc/v/5_2_1', ['exports'], (function (exports) { 'use strict';
9181
9228
  });
9182
9229
  });
9183
9230
  }
9184
- /** version: 5.2.1 */
9231
+ /** version: 6.0.0 */
9185
9232
 
9186
9233
  exports.LightningElement = LightningElement;
9187
9234
  exports.__unstable__ProfilerControl = profilerControl;