@lwc/ssr-runtime 8.13.3 → 8.14.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.
@@ -17,7 +17,7 @@ export declare class ClassList implements DOMTokenList {
17
17
  el: LightningElement;
18
18
  constructor(el: LightningElement);
19
19
  add(...newClassNames: string[]): void;
20
- contains(className: string): any;
20
+ contains(className: string): boolean;
21
21
  remove(...classNamesToRemove: string[]): void;
22
22
  replace(oldClassName: string, newClassName: string): boolean;
23
23
  toggle(classNameToToggle: string, force?: boolean): boolean;
@@ -25,9 +25,9 @@ export declare class ClassList implements DOMTokenList {
25
25
  toString(): string;
26
26
  get length(): number;
27
27
  [index: number]: never;
28
- item(_index: number): string | null;
28
+ item(index: number): string | null;
29
+ forEach(callbackFn: (value: string, key: number, parent: DOMTokenList) => void, thisArg?: any): void;
29
30
  supports(_token: string): boolean;
30
- forEach(_callbackfn: (value: string, key: number, parent: DOMTokenList) => void, _thisArg?: any): void;
31
31
  }
32
32
  export {};
33
33
  //# sourceMappingURL=class-list.d.ts.map
package/dist/index.cjs.js CHANGED
@@ -609,7 +609,7 @@ function setHooks(hooks) {
609
609
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
610
610
  */
611
611
  const DEFAULT_SSR_MODE = 'sync';
612
- /** version: 8.13.3 */
612
+ /** version: 8.14.0 */
613
613
 
614
614
  /*
615
615
  * Copyright (c) 2024, Salesforce, Inc.
@@ -618,25 +618,28 @@ const DEFAULT_SSR_MODE = 'sync';
618
618
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
619
619
  */
620
620
  const MULTI_SPACE = /\s+/g;
621
+ function parseClassName(className) {
622
+ return (className ?? '')
623
+ .split(MULTI_SPACE)
624
+ .map((item) => item.trim())
625
+ .filter(Boolean);
626
+ }
621
627
  class ClassList {
622
628
  constructor(el) {
623
629
  this.el = el;
624
630
  }
625
631
  add(...newClassNames) {
626
- const className = this.el.className;
627
- const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
632
+ const set = new Set(parseClassName(this.el.className));
628
633
  for (const newClassName of newClassNames) {
629
634
  set.add(newClassName);
630
635
  }
631
636
  this.el.className = Array.from(set).join(' ');
632
637
  }
633
638
  contains(className) {
634
- const currentClassNameStr = this.el.className;
635
- return currentClassNameStr.split(MULTI_SPACE).includes(className);
639
+ return parseClassName(this.el.className).includes(className);
636
640
  }
637
641
  remove(...classNamesToRemove) {
638
- const className = this.el.className;
639
- const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
642
+ const set = new Set(parseClassName(this.el.className));
640
643
  for (const newClassName of classNamesToRemove) {
641
644
  set.delete(newClassName);
642
645
  }
@@ -644,8 +647,7 @@ class ClassList {
644
647
  }
645
648
  replace(oldClassName, newClassName) {
646
649
  let classWasReplaced = false;
647
- const className = this.el.className;
648
- const listOfClasses = className.split(MULTI_SPACE).filter(Boolean);
650
+ const listOfClasses = parseClassName(this.el.className);
649
651
  listOfClasses.forEach((value, idx) => {
650
652
  if (value === oldClassName) {
651
653
  classWasReplaced = true;
@@ -656,8 +658,7 @@ class ClassList {
656
658
  return classWasReplaced;
657
659
  }
658
660
  toggle(classNameToToggle, force) {
659
- const classNameStr = this.el.className;
660
- const set = new Set(classNameStr.split(MULTI_SPACE).filter(Boolean));
661
+ const set = new Set(parseClassName(this.el.className));
661
662
  if (!set.has(classNameToToggle) && force !== false) {
662
663
  set.add(classNameToToggle);
663
664
  }
@@ -674,17 +675,18 @@ class ClassList {
674
675
  return this.el.className;
675
676
  }
676
677
  get length() {
677
- const currentClassNameStr = this.el.className ?? '';
678
- return currentClassNameStr.split(MULTI_SPACE).length;
678
+ return parseClassName(this.el.className).length;
679
679
  }
680
- item(_index) {
681
- throw new Error('Method "item" not implemented.');
680
+ item(index) {
681
+ return parseClassName(this.el.className ?? '')[index] ?? null;
682
682
  }
683
- supports(_token) {
684
- throw new Error('Method "supports" not implemented.');
683
+ forEach(callbackFn, thisArg) {
684
+ parseClassName(this.el.className).forEach((value, index) => callbackFn.call(thisArg, value, index, this));
685
685
  }
686
- forEach(_callbackfn, _thisArg) {
687
- throw new Error('Method "forEach" not implemented.');
686
+ // This method is present on DOMTokenList but throws an error in the browser when used
687
+ // in connection with Element#classList.
688
+ supports(_token) {
689
+ throw new TypeError('DOMTokenList has no supported tokens.');
688
690
  }
689
691
  }
690
692
 
@@ -1335,6 +1337,10 @@ class LightningElement {
1335
1337
  [(_LightningElement_props = new WeakMap(), _LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs, publicProperties, privateProperties) {
1336
1338
  __classPrivateFieldSet(this, _LightningElement_props, props, "f");
1337
1339
  __classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
1340
+ // Class should be set explicitly to avoid it being overridden by connectedCallback classList mutation.
1341
+ if (attrs.class) {
1342
+ this.className = attrs.class;
1343
+ }
1338
1344
  // Avoid setting the following types of properties that should not be set:
1339
1345
  // - Properties that are not public.
1340
1346
  // - Properties that are not global.
@@ -1837,5 +1843,5 @@ exports.track = track;
1837
1843
  exports.unwrap = unwrap$1;
1838
1844
  exports.validateStyleTextContents = validateStyleTextContents;
1839
1845
  exports.wire = wire;
1840
- /** version: 8.13.3 */
1846
+ /** version: 8.14.0 */
1841
1847
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.js CHANGED
@@ -605,7 +605,7 @@ function setHooks(hooks) {
605
605
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
606
606
  */
607
607
  const DEFAULT_SSR_MODE = 'sync';
608
- /** version: 8.13.3 */
608
+ /** version: 8.14.0 */
609
609
 
610
610
  /*
611
611
  * Copyright (c) 2024, Salesforce, Inc.
@@ -614,25 +614,28 @@ const DEFAULT_SSR_MODE = 'sync';
614
614
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
615
615
  */
616
616
  const MULTI_SPACE = /\s+/g;
617
+ function parseClassName(className) {
618
+ return (className ?? '')
619
+ .split(MULTI_SPACE)
620
+ .map((item) => item.trim())
621
+ .filter(Boolean);
622
+ }
617
623
  class ClassList {
618
624
  constructor(el) {
619
625
  this.el = el;
620
626
  }
621
627
  add(...newClassNames) {
622
- const className = this.el.className;
623
- const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
628
+ const set = new Set(parseClassName(this.el.className));
624
629
  for (const newClassName of newClassNames) {
625
630
  set.add(newClassName);
626
631
  }
627
632
  this.el.className = Array.from(set).join(' ');
628
633
  }
629
634
  contains(className) {
630
- const currentClassNameStr = this.el.className;
631
- return currentClassNameStr.split(MULTI_SPACE).includes(className);
635
+ return parseClassName(this.el.className).includes(className);
632
636
  }
633
637
  remove(...classNamesToRemove) {
634
- const className = this.el.className;
635
- const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
638
+ const set = new Set(parseClassName(this.el.className));
636
639
  for (const newClassName of classNamesToRemove) {
637
640
  set.delete(newClassName);
638
641
  }
@@ -640,8 +643,7 @@ class ClassList {
640
643
  }
641
644
  replace(oldClassName, newClassName) {
642
645
  let classWasReplaced = false;
643
- const className = this.el.className;
644
- const listOfClasses = className.split(MULTI_SPACE).filter(Boolean);
646
+ const listOfClasses = parseClassName(this.el.className);
645
647
  listOfClasses.forEach((value, idx) => {
646
648
  if (value === oldClassName) {
647
649
  classWasReplaced = true;
@@ -652,8 +654,7 @@ class ClassList {
652
654
  return classWasReplaced;
653
655
  }
654
656
  toggle(classNameToToggle, force) {
655
- const classNameStr = this.el.className;
656
- const set = new Set(classNameStr.split(MULTI_SPACE).filter(Boolean));
657
+ const set = new Set(parseClassName(this.el.className));
657
658
  if (!set.has(classNameToToggle) && force !== false) {
658
659
  set.add(classNameToToggle);
659
660
  }
@@ -670,17 +671,18 @@ class ClassList {
670
671
  return this.el.className;
671
672
  }
672
673
  get length() {
673
- const currentClassNameStr = this.el.className ?? '';
674
- return currentClassNameStr.split(MULTI_SPACE).length;
674
+ return parseClassName(this.el.className).length;
675
675
  }
676
- item(_index) {
677
- throw new Error('Method "item" not implemented.');
676
+ item(index) {
677
+ return parseClassName(this.el.className ?? '')[index] ?? null;
678
678
  }
679
- supports(_token) {
680
- throw new Error('Method "supports" not implemented.');
679
+ forEach(callbackFn, thisArg) {
680
+ parseClassName(this.el.className).forEach((value, index) => callbackFn.call(thisArg, value, index, this));
681
681
  }
682
- forEach(_callbackfn, _thisArg) {
683
- throw new Error('Method "forEach" not implemented.');
682
+ // This method is present on DOMTokenList but throws an error in the browser when used
683
+ // in connection with Element#classList.
684
+ supports(_token) {
685
+ throw new TypeError('DOMTokenList has no supported tokens.');
684
686
  }
685
687
  }
686
688
 
@@ -1331,6 +1333,10 @@ class LightningElement {
1331
1333
  [(_LightningElement_props = new WeakMap(), _LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs, publicProperties, privateProperties) {
1332
1334
  __classPrivateFieldSet(this, _LightningElement_props, props, "f");
1333
1335
  __classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
1336
+ // Class should be set explicitly to avoid it being overridden by connectedCallback classList mutation.
1337
+ if (attrs.class) {
1338
+ this.className = attrs.class;
1339
+ }
1334
1340
  // Avoid setting the following types of properties that should not be set:
1335
1341
  // - Properties that are not public.
1336
1342
  // - Properties that are not global.
@@ -1788,5 +1794,5 @@ function createContextProvider(adapter) {
1788
1794
  }
1789
1795
 
1790
1796
  export { ClassList, LightningElement, SYMBOL__DEFAULT_TEMPLATE, SYMBOL__GENERATE_MARKUP, SYMBOL__SET_INTERNALS, api, connectContext, createContextProvider, createElement, establishContextfulRelationship, fallbackTmpl, fallbackTmplNoYield, freezeTemplate, getComponentDef, hasScopedStaticStylesheets, hot, htmlEscape, isComponentConstructor, mutationTracker, normalizeClass, normalizeTextContent, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, renderAttrs, renderAttrsNoYield, serverSideRenderComponent as renderComponent, renderStylesheets, renderTextContent, renderer, sanitizeAttribute, sanitizeHtmlContent, serverSideRenderComponent, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, toIteratorDirective, track, unwrap$1 as unwrap, validateStyleTextContents, wire };
1791
- /** version: 8.13.3 */
1797
+ /** version: 8.14.0 */
1792
1798
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
5
5
  ],
6
6
  "name": "@lwc/ssr-runtime",
7
- "version": "8.13.3",
7
+ "version": "8.14.0",
8
8
  "description": "Runtime complement to @lwc/ssr-compiler",
9
9
  "keywords": [
10
10
  "lwc",
@@ -48,8 +48,8 @@
48
48
  }
49
49
  },
50
50
  "devDependencies": {
51
- "@lwc/shared": "8.13.3",
52
- "@lwc/engine-core": "8.13.3",
51
+ "@lwc/shared": "8.14.0",
52
+ "@lwc/engine-core": "8.14.0",
53
53
  "observable-membrane": "2.0.0"
54
54
  }
55
55
  }