@lwc/engine-core 2.13.1 → 2.13.2

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.
@@ -4892,20 +4892,9 @@ function removeVM(vm) {
4892
4892
 
4893
4893
  resetComponentStateWhenRemoved(vm);
4894
4894
  }
4895
-
4896
- function getNearestShadowAncestor(vm) {
4897
- let ancestor = vm.owner;
4898
-
4899
- while (!shared.isNull(ancestor) && ancestor.renderMode === 0
4900
- /* Light */
4901
- ) {
4902
- ancestor = ancestor.owner;
4903
- }
4904
-
4905
- return ancestor;
4906
- }
4907
-
4908
4895
  function createVM(elm, ctor, options) {
4896
+ var _a;
4897
+
4909
4898
  const {
4910
4899
  mode,
4911
4900
  owner,
@@ -4933,6 +4922,8 @@ function createVM(elm, ctor, options) {
4933
4922
  oar: shared.create(null),
4934
4923
  cmpTemplate: null,
4935
4924
  renderMode: def.renderMode,
4925
+ shadowMode: computeShadowMode(def, owner),
4926
+ nearestShadowMode: (owner === null || owner === void 0 ? void 0 : owner.shadowRoot) ? owner.shadowMode : (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : null,
4936
4927
  context: {
4937
4928
  stylesheetToken: undefined,
4938
4929
  hasTokenInClass: undefined,
@@ -4945,7 +4936,6 @@ function createVM(elm, ctor, options) {
4945
4936
  },
4946
4937
  // Properties set right after VM creation.
4947
4938
  tro: null,
4948
- shadowMode: null,
4949
4939
  // Properties set by the LightningElement constructor.
4950
4940
  component: null,
4951
4941
  shadowRoot: null,
@@ -4954,7 +4944,6 @@ function createVM(elm, ctor, options) {
4954
4944
  setHook,
4955
4945
  getHook
4956
4946
  };
4957
- vm.shadowMode = computeShadowMode(vm);
4958
4947
  vm.tro = getTemplateReactiveObserver(vm);
4959
4948
 
4960
4949
  if (process.env.NODE_ENV !== 'production') {
@@ -4979,10 +4968,9 @@ function createVM(elm, ctor, options) {
4979
4968
  return vm;
4980
4969
  }
4981
4970
 
4982
- function computeShadowMode(vm) {
4983
- const {
4984
- def
4985
- } = vm;
4971
+ function computeShadowMode(def, owner) {
4972
+ var _a;
4973
+
4986
4974
  let shadowMode;
4987
4975
 
4988
4976
  if (isSyntheticShadowDefined) {
@@ -5005,23 +4993,13 @@ function computeShadowMode(vm) {
5005
4993
  /* Native */
5006
4994
  ;
5007
4995
  } else {
5008
- const shadowAncestor = getNearestShadowAncestor(vm);
5009
-
5010
- if (!shared.isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
5011
- /* Native */
5012
- ) {
5013
- // Transitive support for native Shadow DOM. A component in native mode
5014
- // transitively opts all of its descendants into native.
5015
- shadowMode = 0
5016
- /* Native */
5017
- ;
5018
- } else {
5019
- // Synthetic if neither this component nor any of its ancestors are configured
5020
- // to be native.
5021
- shadowMode = 1
5022
- /* Synthetic */
5023
- ;
5024
- }
4996
+ // Transitive support for native Shadow DOM. A component in native mode
4997
+ // transitively opts all of its descendants into native.
4998
+ // Synthetic if neither this component nor any of its ancestors are configured
4999
+ // to be native.
5000
+ shadowMode = (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : 1
5001
+ /* Synthetic */
5002
+ ;
5025
5003
  }
5026
5004
  } else {
5027
5005
  shadowMode = 1
@@ -6111,6 +6089,29 @@ function setHooks(hooks) {
6111
6089
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6112
6090
  }
6113
6091
 
6092
+ /*
6093
+ * Copyright (c) 2018, salesforce.com, inc.
6094
+ * All rights reserved.
6095
+ * SPDX-License-Identifier: MIT
6096
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6097
+ */
6098
+ /**
6099
+ * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6100
+ * This API is subject to change or being removed.
6101
+ */
6102
+ function getComponentConstructor(elm) {
6103
+ let ctor = null;
6104
+ // intentionally checking for undefined due to some funky libraries patching weakmap.get
6105
+ // to throw when undefined.
6106
+ if (!shared.isUndefined(elm)) {
6107
+ const vm = getAssociatedVMIfPresent(elm);
6108
+ if (!shared.isUndefined(vm)) {
6109
+ ctor = vm.def.ctor;
6110
+ }
6111
+ }
6112
+ return ctor;
6113
+ }
6114
+
6114
6115
  Object.defineProperty(exports, 'setFeatureFlag', {
6115
6116
  enumerable: true,
6116
6117
  get: function () { return features.setFeatureFlag; }
@@ -6127,6 +6128,7 @@ exports.createContextProvider = createContextProvider;
6127
6128
  exports.createVM = createVM;
6128
6129
  exports.disconnectRootElement = disconnectRootElement;
6129
6130
  exports.getAssociatedVMIfPresent = getAssociatedVMIfPresent;
6131
+ exports.getComponentConstructor = getComponentConstructor;
6130
6132
  exports.getComponentDef = getComponentDef;
6131
6133
  exports.getComponentHtmlPrototype = getComponentHtmlPrototype;
6132
6134
  exports.getUpgradableConstructor = getUpgradableConstructor;
@@ -6185,4 +6187,4 @@ exports.swapTemplate = swapTemplate;
6185
6187
  exports.track = track;
6186
6188
  exports.unwrap = unwrap;
6187
6189
  exports.wire = wire;
6188
- /* version: 2.13.1 */
6190
+ /* version: 2.13.2 */
@@ -4889,20 +4889,9 @@ function removeVM(vm) {
4889
4889
 
4890
4890
  resetComponentStateWhenRemoved(vm);
4891
4891
  }
4892
-
4893
- function getNearestShadowAncestor(vm) {
4894
- let ancestor = vm.owner;
4895
-
4896
- while (!isNull(ancestor) && ancestor.renderMode === 0
4897
- /* Light */
4898
- ) {
4899
- ancestor = ancestor.owner;
4900
- }
4901
-
4902
- return ancestor;
4903
- }
4904
-
4905
4892
  function createVM(elm, ctor, options) {
4893
+ var _a;
4894
+
4906
4895
  const {
4907
4896
  mode,
4908
4897
  owner,
@@ -4930,6 +4919,8 @@ function createVM(elm, ctor, options) {
4930
4919
  oar: create(null),
4931
4920
  cmpTemplate: null,
4932
4921
  renderMode: def.renderMode,
4922
+ shadowMode: computeShadowMode(def, owner),
4923
+ nearestShadowMode: (owner === null || owner === void 0 ? void 0 : owner.shadowRoot) ? owner.shadowMode : (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : null,
4933
4924
  context: {
4934
4925
  stylesheetToken: undefined,
4935
4926
  hasTokenInClass: undefined,
@@ -4942,7 +4933,6 @@ function createVM(elm, ctor, options) {
4942
4933
  },
4943
4934
  // Properties set right after VM creation.
4944
4935
  tro: null,
4945
- shadowMode: null,
4946
4936
  // Properties set by the LightningElement constructor.
4947
4937
  component: null,
4948
4938
  shadowRoot: null,
@@ -4951,7 +4941,6 @@ function createVM(elm, ctor, options) {
4951
4941
  setHook,
4952
4942
  getHook
4953
4943
  };
4954
- vm.shadowMode = computeShadowMode(vm);
4955
4944
  vm.tro = getTemplateReactiveObserver(vm);
4956
4945
 
4957
4946
  if (process.env.NODE_ENV !== 'production') {
@@ -4976,10 +4965,9 @@ function createVM(elm, ctor, options) {
4976
4965
  return vm;
4977
4966
  }
4978
4967
 
4979
- function computeShadowMode(vm) {
4980
- const {
4981
- def
4982
- } = vm;
4968
+ function computeShadowMode(def, owner) {
4969
+ var _a;
4970
+
4983
4971
  let shadowMode;
4984
4972
 
4985
4973
  if (isSyntheticShadowDefined) {
@@ -5002,23 +4990,13 @@ function computeShadowMode(vm) {
5002
4990
  /* Native */
5003
4991
  ;
5004
4992
  } else {
5005
- const shadowAncestor = getNearestShadowAncestor(vm);
5006
-
5007
- if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
5008
- /* Native */
5009
- ) {
5010
- // Transitive support for native Shadow DOM. A component in native mode
5011
- // transitively opts all of its descendants into native.
5012
- shadowMode = 0
5013
- /* Native */
5014
- ;
5015
- } else {
5016
- // Synthetic if neither this component nor any of its ancestors are configured
5017
- // to be native.
5018
- shadowMode = 1
5019
- /* Synthetic */
5020
- ;
5021
- }
4993
+ // Transitive support for native Shadow DOM. A component in native mode
4994
+ // transitively opts all of its descendants into native.
4995
+ // Synthetic if neither this component nor any of its ancestors are configured
4996
+ // to be native.
4997
+ shadowMode = (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : 1
4998
+ /* Synthetic */
4999
+ ;
5022
5000
  }
5023
5001
  } else {
5024
5002
  shadowMode = 1
@@ -6108,5 +6086,28 @@ function setHooks(hooks) {
6108
6086
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6109
6087
  }
6110
6088
 
6111
- export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setAddEventListener, setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setHooks, setInsert, setInsertGlobalStylesheet, setInsertStylesheet, setIsConnected, setIsHydrating, setIsNativeShadowDefined, setIsSyntheticShadowDefined, setNextSibling, setQuerySelector, setQuerySelectorAll, setRemove, setRemoveAttribute, setRemoveEventListener, setSetAttribute, setSetCSSStyleProperty, setSetProperty, setSetText, setSsr, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6112
- /* version: 2.13.1 */
6089
+ /*
6090
+ * Copyright (c) 2018, salesforce.com, inc.
6091
+ * All rights reserved.
6092
+ * SPDX-License-Identifier: MIT
6093
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6094
+ */
6095
+ /**
6096
+ * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6097
+ * This API is subject to change or being removed.
6098
+ */
6099
+ function getComponentConstructor(elm) {
6100
+ let ctor = null;
6101
+ // intentionally checking for undefined due to some funky libraries patching weakmap.get
6102
+ // to throw when undefined.
6103
+ if (!isUndefined$1(elm)) {
6104
+ const vm = getAssociatedVMIfPresent(elm);
6105
+ if (!isUndefined$1(vm)) {
6106
+ ctor = vm.def.ctor;
6107
+ }
6108
+ }
6109
+ return ctor;
6110
+ }
6111
+
6112
+ export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setAddEventListener, setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setHooks, setInsert, setInsertGlobalStylesheet, setInsertStylesheet, setIsConnected, setIsHydrating, setIsNativeShadowDefined, setIsSyntheticShadowDefined, setNextSibling, setQuerySelector, setQuerySelectorAll, setRemove, setRemoveAttribute, setRemoveEventListener, setSetAttribute, setSetCSSStyleProperty, setSetProperty, setSetText, setSsr, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6113
+ /* version: 2.13.2 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.13.1",
3
+ "version": "2.13.2",
4
4
  "description": "Core LWC engine APIs.",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -25,8 +25,8 @@
25
25
  "types/"
26
26
  ],
27
27
  "dependencies": {
28
- "@lwc/features": "2.13.1",
29
- "@lwc/shared": "2.13.1"
28
+ "@lwc/features": "2.13.2",
29
+ "@lwc/shared": "2.13.2"
30
30
  },
31
31
  "devDependencies": {
32
32
  "observable-membrane": "2.0.0"
@@ -0,0 +1,6 @@
1
+ import { LightningElement } from './base-lightning-element';
2
+ /**
3
+ * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
4
+ * This API is subject to change or being removed.
5
+ */
6
+ export declare function getComponentConstructor(elm: HTMLElement): typeof LightningElement | null;
@@ -19,5 +19,6 @@ export { profilerControl as __unstable__ProfilerControl } from './profiler';
19
19
  export { getUpgradableConstructor } from './upgradable-element';
20
20
  export { swapTemplate, swapComponent, swapStyle } from './hot-swaps';
21
21
  export { setHooks } from './overridable-hooks';
22
+ export { getComponentConstructor } from './get-component-constructor';
22
23
  export type { ConfigValue as WireConfigValue, ContextValue as WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, } from './wiring';
23
24
  export { setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setInsert, setInsertGlobalStylesheet, setInsertStylesheet, setIsConnected, setIsHydrating, setIsNativeShadowDefined, setIsSyntheticShadowDefined, setNextSibling, setQuerySelector, setQuerySelectorAll, setRemove, setRemoveAttribute, setRemoveEventListener, setSetAttribute, setSetCSSStyleProperty, setSetProperty, setSetText, setSsr, setAddEventListener, } from '../renderer';
@@ -63,8 +63,11 @@ export interface VM<N = HostNode, E = HostElement> {
63
63
  /** The owner VM or null for root elements. */
64
64
  readonly owner: VM<N, E> | null;
65
65
  /** Rendering operations associated with the VM */
66
- renderMode: RenderMode;
66
+ readonly renderMode: RenderMode;
67
67
  shadowMode: ShadowMode;
68
+ /** Transitive support for native Shadow DOM. A component in native mode
69
+ * transitively opts all of its descendants into native. */
70
+ readonly nearestShadowMode: ShadowMode | null;
68
71
  /** The component creation index. */
69
72
  idx: number;
70
73
  /** Component state, analogous to Element.isConnected */