@lwc/engine-core 7.0.1 → 7.0.3-alpha.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.
@@ -6,6 +6,7 @@ export declare const EmptyObject: any;
6
6
  export declare const EmptyArray: never[];
7
7
  export declare function addCallbackToNextTick(callback: Callback): void;
8
8
  export declare function guid(): string;
9
+ export declare function shouldUseNativeCustomElementLifecycle(ctor: LightningElementConstructor): boolean;
9
10
  export declare function parseStyleText(cssText: string): {
10
11
  [name: string]: string;
11
12
  };
package/dist/index.cjs.js CHANGED
@@ -449,6 +449,14 @@ function guid() {
449
449
  }
450
450
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
451
451
  }
452
+ function shouldUseNativeCustomElementLifecycle(ctor) {
453
+ if (lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
454
+ // temporary "kill switch"
455
+ return false;
456
+ }
457
+ const apiVersion = getComponentAPIVersion(ctor);
458
+ return shared.isAPIFeatureEnabled(7 /* APIFeature.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE */, apiVersion);
459
+ }
452
460
  // Borrowed from Vue template compiler.
453
461
  // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
454
462
  const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
@@ -499,7 +507,7 @@ function assertNotProd() {
499
507
  function shouldBeFormAssociated(Ctor) {
500
508
  const ctorFormAssociated = Boolean(Ctor.formAssociated);
501
509
  const apiVersion = getComponentAPIVersion(Ctor);
502
- const apiFeatureEnabled = shared.isAPIFeatureEnabled(7 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion);
510
+ const apiFeatureEnabled = shared.isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion);
503
511
  if (process.env.NODE_ENV !== 'production' && ctorFormAssociated && !apiFeatureEnabled) {
504
512
  const tagName = getComponentRegisteredName(Ctor);
505
513
  logWarnOnce(`Component <${tagName}> set static formAssociated to true, but form ` +
@@ -1742,7 +1750,7 @@ LightningElement.prototype = {
1742
1750
  attachInternals() {
1743
1751
  const vm = getAssociatedVM(this);
1744
1752
  const { elm, apiVersion, renderer: { attachInternals }, } = vm;
1745
- if (!shared.isAPIFeatureEnabled(7 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion)) {
1753
+ if (!shared.isAPIFeatureEnabled(8 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion)) {
1746
1754
  throw new Error(`The attachInternals API is only supported in API version 61 and above. ` +
1747
1755
  `The current version is ${apiVersion}. ` +
1748
1756
  `To use this API, update the LWC component API version. https://lwc.dev/guide/versioning`);
@@ -1782,7 +1790,7 @@ LightningElement.prototype = {
1782
1790
  shared.assert.fail('this.hostElement is not supported in this environment');
1783
1791
  }
1784
1792
  const apiVersion = getComponentAPIVersion(vm.def.ctor);
1785
- if (!shared.isAPIFeatureEnabled(8 /* APIFeature.ENABLE_THIS_DOT_HOST_ELEMENT */, apiVersion)) {
1793
+ if (!shared.isAPIFeatureEnabled(9 /* APIFeature.ENABLE_THIS_DOT_HOST_ELEMENT */, apiVersion)) {
1786
1794
  if (process.env.NODE_ENV !== 'production') {
1787
1795
  logWarnOnce('The `this.hostElement` API within LightningElement is ' +
1788
1796
  'only supported in API version 62 and above. Increase the API version to use it.');
@@ -1924,7 +1932,7 @@ LightningElement.prototype = {
1924
1932
  get style() {
1925
1933
  const { elm, renderer, def } = getAssociatedVM(this);
1926
1934
  const apiVersion = getComponentAPIVersion(def.ctor);
1927
- if (!shared.isAPIFeatureEnabled(9 /* APIFeature.ENABLE_THIS_DOT_STYLE */, apiVersion)) {
1935
+ if (!shared.isAPIFeatureEnabled(10 /* APIFeature.ENABLE_THIS_DOT_STYLE */, apiVersion)) {
1928
1936
  if (process.env.NODE_ENV !== 'production') {
1929
1937
  logWarnOnce('The `this.style` API within LightningElement returning the CSSStyleDeclaration is ' +
1930
1938
  'only supported in API version 62 and above. Increase the API version to use it.');
@@ -4496,7 +4504,7 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
4496
4504
  // compiler may generate tagnames with uppercase letters so - for backwards
4497
4505
  // compatibility, we lower case the tagname here.
4498
4506
  const normalizedTagname = sel.toLowerCase();
4499
- const useNativeLifecycle = !lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE;
4507
+ const useNativeLifecycle = shouldUseNativeCustomElementLifecycle(ctor);
4500
4508
  const isFormAssociated = shouldBeFormAssociated(ctor);
4501
4509
  const elm = createCustomElement(normalizedTagname, upgradeCallback, useNativeLifecycle, isFormAssociated);
4502
4510
  vnode.elm = elm;
@@ -6373,7 +6381,7 @@ function resetComponentStateWhenRemoved(vm) {
6373
6381
  // old vnode.children is removed from the DOM.
6374
6382
  function removeVM(vm) {
6375
6383
  if (process.env.NODE_ENV !== 'production') {
6376
- if (lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
6384
+ if (!shouldUseNativeCustomElementLifecycle(vm.component.constructor)) {
6377
6385
  // With native lifecycle, we cannot be certain that connectedCallback was called before a component
6378
6386
  // was removed from the VDOM. If the component is disconnected, then connectedCallback will not fire
6379
6387
  // in native mode, although it will fire in synthetic mode due to appendChild triggering it.
@@ -6697,7 +6705,7 @@ function runConnectedCallback(vm) {
6697
6705
  // This test only makes sense in the browser, with synthetic lifecycle, and when reporting is enabled or
6698
6706
  // we're in dev mode. This is to detect a particular issue with synthetic lifecycle.
6699
6707
  if (process.env.IS_BROWSER &&
6700
- lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE &&
6708
+ !shouldUseNativeCustomElementLifecycle(vm.component.constructor) &&
6701
6709
  (process.env.NODE_ENV !== 'production' || isReportingEnabled())) {
6702
6710
  if (!vm.renderer.isConnected(vm.elm)) {
6703
6711
  if (process.env.NODE_ENV !== 'production') {
@@ -8068,5 +8076,5 @@ exports.swapTemplate = swapTemplate;
8068
8076
  exports.track = track;
8069
8077
  exports.unwrap = unwrap;
8070
8078
  exports.wire = wire;
8071
- /** version: 7.0.1 */
8079
+ /** version: 7.0.0 */
8072
8080
  //# sourceMappingURL=index.cjs.js.map