@lwc/engine-core 2.24.0 → 2.25.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.
@@ -3131,6 +3131,14 @@ function getScopeTokenClass(owner) {
3131
3131
  const { cmpTemplate, context } = owner;
3132
3132
  return (context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) || null;
3133
3133
  }
3134
+ /**
3135
+ * This function returns the host style token for a custom element if it
3136
+ * exists. Otherwise it returns null.
3137
+ */
3138
+ function getStylesheetTokenHost(vnode) {
3139
+ const { template: { stylesheetToken }, } = getComponentInternalDef(vnode.ctor);
3140
+ return !shared.isUndefined(stylesheetToken) ? makeHostToken(stylesheetToken) : null;
3141
+ }
3134
3142
  function getNearestNativeShadowComponent(vm) {
3135
3143
  const owner = getNearestShadowComponent(vm);
3136
3144
  if (!shared.isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
@@ -3248,6 +3256,9 @@ function isVBaseElement(vnode) {
3248
3256
  function isSameVnode(vnode1, vnode2) {
3249
3257
  return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
3250
3258
  }
3259
+ function isVCustomElement(vnode) {
3260
+ return vnode.type === 3 /* VNodeType.CustomElement */;
3261
+ }
3251
3262
 
3252
3263
  /*
3253
3264
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6541,6 +6552,7 @@ function validateClassAttr(vnode, elm, renderer) {
6541
6552
  let { className, classMap } = data;
6542
6553
  const { getProperty, getClassList } = renderer;
6543
6554
  const scopedToken = getScopeTokenClass(owner);
6555
+ const stylesheetTokenHost = isVCustomElement(vnode) ? getStylesheetTokenHost(vnode) : null;
6544
6556
  // Classnames for scoped CSS are added directly to the DOM during rendering,
6545
6557
  // or to the VDOM on the server in the case of SSR. As such, these classnames
6546
6558
  // are never present in VDOM nodes in the browser.
@@ -6549,10 +6561,17 @@ function validateClassAttr(vnode, elm, renderer) {
6549
6561
  // are rendered during SSR. This needs to be accounted for when validating.
6550
6562
  if (scopedToken) {
6551
6563
  if (!shared.isUndefined(className)) {
6552
- className = `${scopedToken} ${className}`;
6564
+ className = shared.isNull(stylesheetTokenHost)
6565
+ ? `${scopedToken} ${className}`
6566
+ : `${scopedToken} ${className} ${stylesheetTokenHost}`;
6553
6567
  }
6554
6568
  else if (!shared.isUndefined(classMap)) {
6555
- classMap = Object.assign(Object.assign({}, classMap), { [scopedToken]: true });
6569
+ classMap = Object.assign(Object.assign(Object.assign({}, classMap), { [scopedToken]: true }), (shared.isNull(stylesheetTokenHost) ? {} : { [stylesheetTokenHost]: true }));
6570
+ }
6571
+ else {
6572
+ className = shared.isNull(stylesheetTokenHost)
6573
+ ? `${scopedToken}`
6574
+ : `${scopedToken} ${stylesheetTokenHost}`;
6556
6575
  }
6557
6576
  }
6558
6577
  let nodesAreCompatible = true;
@@ -6833,4 +6852,4 @@ exports.swapTemplate = swapTemplate;
6833
6852
  exports.track = track;
6834
6853
  exports.unwrap = unwrap;
6835
6854
  exports.wire = wire;
6836
- /* version: 2.24.0 */
6855
+ /* version: 2.25.0 */
@@ -3128,6 +3128,14 @@ function getScopeTokenClass(owner) {
3128
3128
  const { cmpTemplate, context } = owner;
3129
3129
  return (context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) || null;
3130
3130
  }
3131
+ /**
3132
+ * This function returns the host style token for a custom element if it
3133
+ * exists. Otherwise it returns null.
3134
+ */
3135
+ function getStylesheetTokenHost(vnode) {
3136
+ const { template: { stylesheetToken }, } = getComponentInternalDef(vnode.ctor);
3137
+ return !isUndefined$1(stylesheetToken) ? makeHostToken(stylesheetToken) : null;
3138
+ }
3131
3139
  function getNearestNativeShadowComponent(vm) {
3132
3140
  const owner = getNearestShadowComponent(vm);
3133
3141
  if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
@@ -3245,6 +3253,9 @@ function isVBaseElement(vnode) {
3245
3253
  function isSameVnode(vnode1, vnode2) {
3246
3254
  return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
3247
3255
  }
3256
+ function isVCustomElement(vnode) {
3257
+ return vnode.type === 3 /* VNodeType.CustomElement */;
3258
+ }
3248
3259
 
3249
3260
  /*
3250
3261
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6538,6 +6549,7 @@ function validateClassAttr(vnode, elm, renderer) {
6538
6549
  let { className, classMap } = data;
6539
6550
  const { getProperty, getClassList } = renderer;
6540
6551
  const scopedToken = getScopeTokenClass(owner);
6552
+ const stylesheetTokenHost = isVCustomElement(vnode) ? getStylesheetTokenHost(vnode) : null;
6541
6553
  // Classnames for scoped CSS are added directly to the DOM during rendering,
6542
6554
  // or to the VDOM on the server in the case of SSR. As such, these classnames
6543
6555
  // are never present in VDOM nodes in the browser.
@@ -6546,10 +6558,17 @@ function validateClassAttr(vnode, elm, renderer) {
6546
6558
  // are rendered during SSR. This needs to be accounted for when validating.
6547
6559
  if (scopedToken) {
6548
6560
  if (!isUndefined$1(className)) {
6549
- className = `${scopedToken} ${className}`;
6561
+ className = isNull(stylesheetTokenHost)
6562
+ ? `${scopedToken} ${className}`
6563
+ : `${scopedToken} ${className} ${stylesheetTokenHost}`;
6550
6564
  }
6551
6565
  else if (!isUndefined$1(classMap)) {
6552
- classMap = Object.assign(Object.assign({}, classMap), { [scopedToken]: true });
6566
+ classMap = Object.assign(Object.assign(Object.assign({}, classMap), { [scopedToken]: true }), (isNull(stylesheetTokenHost) ? {} : { [stylesheetTokenHost]: true }));
6567
+ }
6568
+ else {
6569
+ className = isNull(stylesheetTokenHost)
6570
+ ? `${scopedToken}`
6571
+ : `${scopedToken} ${stylesheetTokenHost}`;
6553
6572
  }
6554
6573
  }
6555
6574
  let nodesAreCompatible = true;
@@ -6793,4 +6812,4 @@ function getComponentConstructor(elm) {
6793
6812
  }
6794
6813
 
6795
6814
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6796
- /* version: 2.24.0 */
6815
+ /* version: 2.25.0 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.24.0",
3
+ "version": "2.25.0",
4
4
  "description": "Core LWC engine APIs.",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -24,8 +24,8 @@
24
24
  "types/"
25
25
  ],
26
26
  "dependencies": {
27
- "@lwc/features": "2.24.0",
28
- "@lwc/shared": "2.24.0"
27
+ "@lwc/features": "2.25.0",
28
+ "@lwc/shared": "2.25.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "observable-membrane": "2.0.0"
@@ -1,6 +1,6 @@
1
1
  import { VM } from './vm';
2
2
  import { Template } from './template';
3
- import { VNode } from './vnodes';
3
+ import { VCustomElement, VNode } from './vnodes';
4
4
  /**
5
5
  * Function producing style based on a host and a shadow selector. This function is invoked by
6
6
  * the engine with different values depending on the mode that the component is running on.
@@ -20,4 +20,9 @@ export declare function getStylesheetsContent(vm: VM, template: Template): strin
20
20
  * it returns null.
21
21
  */
22
22
  export declare function getScopeTokenClass(owner: VM): string | null;
23
+ /**
24
+ * This function returns the host style token for a custom element if it
25
+ * exists. Otherwise it returns null.
26
+ */
27
+ export declare function getStylesheetTokenHost(vnode: VCustomElement): string | null;
23
28
  export declare function createStylesheet(vm: VM, stylesheets: string[]): VNode[] | null;
@@ -80,3 +80,4 @@ export interface VElementData extends VNodeData {
80
80
  }
81
81
  export declare function isVBaseElement(vnode: VNode): vnode is VElement | VCustomElement;
82
82
  export declare function isSameVnode(vnode1: VNode, vnode2: VNode): boolean;
83
+ export declare function isVCustomElement(vnode: VBaseElement): vnode is VCustomElement;