@lwc/ssr-runtime 8.12.7-alpha.0 → 8.13.0-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.
package/dist/index.js CHANGED
@@ -254,48 +254,26 @@ assign,
254
254
  create,
255
255
  /** Detached {@linkcode Object.defineProperties}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties MDN Reference}. */
256
256
  defineProperties,
257
- /** Detached {@linkcode Object.defineProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty MDN Reference}. */
258
- defineProperty,
259
257
  /** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
260
258
  entries,
261
- /** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
262
- freeze,
263
- /** Detached {@linkcode Object.fromEntries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries MDN Reference}. */
264
- fromEntries,
265
- /** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
266
- getOwnPropertyDescriptor: getOwnPropertyDescriptor$1,
267
- /** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
268
- getOwnPropertyDescriptors,
269
259
  /** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
270
260
  getOwnPropertyNames: getOwnPropertyNames$1,
271
- /** Detached {@linkcode Object.getOwnPropertySymbols}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols MDN Reference}. */
272
- getOwnPropertySymbols: getOwnPropertySymbols$1,
273
- /** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
274
- getPrototypeOf: getPrototypeOf$1,
275
261
  /** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
276
262
  hasOwnProperty: hasOwnProperty$1,
277
- /** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
278
- isFrozen,
279
263
  /** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
280
- keys,
281
- /** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */
282
- seal,
283
- /** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
284
- setPrototypeOf, } = Object;
264
+ keys} = Object;
285
265
  const {
286
266
  /** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
287
- isArray: isArray$1,
288
- /** Detached {@linkcode Array.from}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from MDN Reference}. */
289
- from: ArrayFrom, } = Array;
267
+ isArray: isArray$1} = Array;
290
268
  // For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
291
269
  // though it works fine for one, e.g. isArray), so comments for these are added to the export
292
270
  // statement, rather than this declaration.
293
- const { concat: ArrayConcat$1, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, // Weird anomaly!
271
+ const { join: ArrayJoin, map: ArrayMap, forEach, // Weird anomaly!
294
272
  } = Array.prototype;
295
273
  /** Detached {@linkcode String.fromCharCode}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode MDN Reference}. */
296
274
  const { fromCharCode: StringFromCharCode } = String;
297
275
  // No JSDocs here - see comment for Array.prototype
298
- const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
276
+ const { charCodeAt: StringCharCodeAt, replace: StringReplace, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
299
277
  /**
300
278
  * Determines whether the argument is `undefined`.
301
279
  * @param obj Value to test
@@ -627,7 +605,7 @@ function setHooks(hooks) {
627
605
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
628
606
  */
629
607
  const DEFAULT_SSR_MODE = 'sync';
630
- /** version: 8.12.2 */
608
+ /** version: 8.13.0 */
631
609
 
632
610
  /*
633
611
  * Copyright (c) 2024, Salesforce, Inc.
@@ -691,6 +669,10 @@ class ClassList {
691
669
  toString() {
692
670
  return this.el.className;
693
671
  }
672
+ get length() {
673
+ const currentClassNameStr = this.el.className ?? '';
674
+ return currentClassNameStr.split(MULTI_SPACE).length;
675
+ }
694
676
  item(_index) {
695
677
  throw new Error('Method "item" not implemented.');
696
678
  }
@@ -700,10 +682,206 @@ class ClassList {
700
682
  forEach(_callbackfn, _thisArg) {
701
683
  throw new Error('Method "forEach" not implemented.');
702
684
  }
703
- get length() {
704
- throw new Error('Property "length" not implemented.');
685
+ }
686
+
687
+ /******************************************************************************
688
+ Copyright (c) Microsoft Corporation.
689
+
690
+ Permission to use, copy, modify, and/or distribute this software for any
691
+ purpose with or without fee is hereby granted.
692
+
693
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
694
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
695
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
696
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
697
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
698
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
699
+ PERFORMANCE OF THIS SOFTWARE.
700
+ ***************************************************************************** */
701
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
702
+
703
+
704
+ function __classPrivateFieldGet(receiver, state, kind, f) {
705
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
706
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
707
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
708
+ }
709
+
710
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
711
+ if (kind === "m") throw new TypeError("Private method is not writable");
712
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
713
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
714
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
715
+ }
716
+
717
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
718
+ var e = new Error(message);
719
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
720
+ };
721
+
722
+ /*
723
+ * Copyright (c) 2024, Salesforce, Inc.
724
+ * All rights reserved.
725
+ * SPDX-License-Identifier: MIT
726
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
727
+ */
728
+ var _MutationTracker_enabledSet, _MutationTracker_mutationMap;
729
+ class MutationTracker {
730
+ constructor() {
731
+ _MutationTracker_enabledSet.set(this, new WeakSet());
732
+ _MutationTracker_mutationMap.set(this, new WeakMap());
733
+ }
734
+ add(instance, attrName) {
735
+ if (__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").has(instance)) {
736
+ let mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
737
+ if (!mutatedAttrs) {
738
+ mutatedAttrs = new Set();
739
+ __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").set(instance, mutatedAttrs);
740
+ }
741
+ mutatedAttrs.add(attrName.toLowerCase());
742
+ }
743
+ }
744
+ enable(instance) {
745
+ __classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").add(instance);
746
+ }
747
+ disable(instance) {
748
+ __classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").delete(instance);
749
+ }
750
+ renderMutatedAttrs(instance) {
751
+ const mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
752
+ if (mutatedAttrs) {
753
+ return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
754
+ }
755
+ else {
756
+ return '';
757
+ }
705
758
  }
706
759
  }
760
+ _MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
761
+ const mutationTracker = new MutationTracker();
762
+
763
+ /*
764
+ * Copyright (c) 2024, Salesforce, Inc.
765
+ * All rights reserved.
766
+ * SPDX-License-Identifier: MIT
767
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
768
+ */
769
+ /**
770
+ * Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
771
+ */
772
+ const stringDescriptor = (attrName) => ({
773
+ configurable: true,
774
+ enumerable: true,
775
+ get() {
776
+ return this.getAttribute(attrName);
777
+ },
778
+ set(newValue) {
779
+ const currentValue = this.getAttribute(attrName);
780
+ const normalizedValue = String(newValue);
781
+ if (normalizedValue !== currentValue) {
782
+ this.setAttribute(attrName, normalizedValue);
783
+ }
784
+ },
785
+ });
786
+ /** Descriptor for a boolean that checks for `attr="true"` or `attr="false"`, e.g. `spellcheck` and `draggable`. */
787
+ const explicitBooleanDescriptor = (attrName, defaultValue) => ({
788
+ configurable: true,
789
+ enumerable: true,
790
+ get() {
791
+ const value = this.getAttribute(attrName);
792
+ if (value === null)
793
+ return defaultValue;
794
+ // spellcheck=false => false, everything else => true
795
+ // draggable=true => true, everything else => false
796
+ return value.toLowerCase() === String(defaultValue) ? defaultValue : !defaultValue;
797
+ },
798
+ set(newValue) {
799
+ const currentValue = this.getAttribute(attrName);
800
+ const normalizedValue = String(Boolean(newValue));
801
+ if (normalizedValue !== currentValue) {
802
+ this.setAttribute(attrName, normalizedValue);
803
+ }
804
+ },
805
+ });
806
+ /**
807
+ * Descriptor for a "true" boolean attribute that checks solely for presence, e.g. `hidden`.
808
+ */
809
+ const booleanAttributeDescriptor = (attrName) => ({
810
+ configurable: true,
811
+ enumerable: true,
812
+ get() {
813
+ return this.hasAttribute(attrName);
814
+ },
815
+ set(newValue) {
816
+ const hasAttribute = this.hasAttribute(attrName);
817
+ if (newValue) {
818
+ if (!hasAttribute) {
819
+ this.setAttribute(attrName, '');
820
+ }
821
+ }
822
+ else {
823
+ if (hasAttribute) {
824
+ this.removeAttribute(attrName);
825
+ }
826
+ }
827
+ },
828
+ });
829
+ /**
830
+ * Descriptor for ARIA reflections, e.g. `ariaLabel` and `role`.
831
+ */
832
+ const ariaDescriptor = (attrName) => ({
833
+ configurable: true,
834
+ enumerable: true,
835
+ get() {
836
+ return this.getAttribute(attrName);
837
+ },
838
+ set(newValue) {
839
+ const currentValue = this.getAttribute(attrName);
840
+ if (newValue !== currentValue) {
841
+ // TODO [#3284]: According to the spec, IDL nullable type values
842
+ // (null and undefined) should remove the attribute; however, we
843
+ // only do so in the case of null for historical reasons.
844
+ if (isNull(newValue)) {
845
+ this.removeAttribute(attrName);
846
+ }
847
+ else {
848
+ this.setAttribute(attrName, toString(newValue));
849
+ }
850
+ }
851
+ },
852
+ });
853
+ const tabIndexDescriptor = () => ({
854
+ configurable: true,
855
+ enumerable: true,
856
+ get() {
857
+ const str = this.getAttribute('tabindex');
858
+ const num = Number(str);
859
+ return isFinite(num) ? Math.trunc(num) : -1;
860
+ },
861
+ set(newValue) {
862
+ const currentValue = this.getAttribute('tabindex');
863
+ const num = Number(newValue);
864
+ const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
865
+ if (normalizedValue !== currentValue) {
866
+ this.setAttribute('tabindex', toString(newValue));
867
+ }
868
+ },
869
+ });
870
+ const descriptors = {
871
+ accessKey: stringDescriptor('accesskey'),
872
+ dir: stringDescriptor('dir'),
873
+ draggable: explicitBooleanDescriptor('draggable', true),
874
+ hidden: booleanAttributeDescriptor('hidden'),
875
+ id: stringDescriptor('id'),
876
+ lang: stringDescriptor('lang'),
877
+ spellcheck: explicitBooleanDescriptor('spellcheck', false),
878
+ tabIndex: tabIndexDescriptor(),
879
+ title: stringDescriptor('title'),
880
+ };
881
+ // Add descriptors for ARIA attributes
882
+ for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {
883
+ descriptors[propName] = ariaDescriptor(attrName);
884
+ }
707
885
 
708
886
  /**
709
887
  * Copyright (C) 2017 salesforce.com, inc.
@@ -1132,256 +1310,49 @@ function getReadOnlyProxy(value) {
1132
1310
  return reactiveMembrane.getReadOnlyProxy(value);
1133
1311
  }
1134
1312
 
1135
- /******************************************************************************
1136
- Copyright (c) Microsoft Corporation.
1137
-
1138
- Permission to use, copy, modify, and/or distribute this software for any
1139
- purpose with or without fee is hereby granted.
1140
-
1141
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1142
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1143
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1144
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1145
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1146
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1147
- PERFORMANCE OF THIS SOFTWARE.
1148
- ***************************************************************************** */
1149
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
1150
-
1151
-
1152
- function __classPrivateFieldGet(receiver, state, kind, f) {
1153
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1154
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1155
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1156
- }
1157
-
1158
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
1159
- if (kind === "m") throw new TypeError("Private method is not writable");
1160
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1161
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1162
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1163
- }
1164
-
1165
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1166
- var e = new Error(message);
1167
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1168
- };
1169
-
1170
- /*
1171
- * Copyright (c) 2024, Salesforce, Inc.
1172
- * All rights reserved.
1173
- * SPDX-License-Identifier: MIT
1174
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1175
- */
1176
- var _MutationTracker_enabledSet, _MutationTracker_mutationMap;
1177
- class MutationTracker {
1178
- constructor() {
1179
- _MutationTracker_enabledSet.set(this, new WeakSet());
1180
- _MutationTracker_mutationMap.set(this, new WeakMap());
1181
- }
1182
- add(instance, attrName) {
1183
- if (__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").has(instance)) {
1184
- let mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
1185
- if (!mutatedAttrs) {
1186
- mutatedAttrs = new Set();
1187
- __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").set(instance, mutatedAttrs);
1188
- }
1189
- mutatedAttrs.add(attrName.toLowerCase());
1190
- }
1191
- }
1192
- enable(instance) {
1193
- __classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").add(instance);
1194
- }
1195
- disable(instance) {
1196
- __classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").delete(instance);
1197
- }
1198
- renderMutatedAttrs(instance) {
1199
- const mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
1200
- if (mutatedAttrs) {
1201
- return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
1202
- }
1203
- else {
1204
- return '';
1205
- }
1206
- }
1207
- }
1208
- _MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
1209
- const mutationTracker = new MutationTracker();
1210
-
1211
- /*
1212
- * Copyright (c) 2024, Salesforce, Inc.
1213
- * All rights reserved.
1214
- * SPDX-License-Identifier: MIT
1215
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1216
- */
1217
- /**
1218
- * Filters out the following types of properties that should not be set.
1219
- * - Properties that are not public.
1220
- * - Properties that are not global.
1221
- * - Properties that are global but are internally overridden.
1222
- */
1223
- function filterProperties(props, publicFields, privateFields) {
1224
- const propsToAssign = create(null);
1225
- const publicFieldSet = new Set(publicFields);
1226
- const privateFieldSet = new Set(privateFields);
1227
- keys(props).forEach((propName) => {
1228
- const attrName = htmlPropertyToAttribute(propName);
1229
- if (publicFieldSet.has(propName) ||
1230
- ((REFLECTIVE_GLOBAL_PROPERTY_SET.has(propName) || isAriaAttribute(attrName)) &&
1231
- !privateFieldSet.has(propName))) {
1232
- propsToAssign[propName] = props[propName];
1233
- }
1234
- });
1235
- return propsToAssign;
1236
- }
1237
- /**
1238
- * Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
1239
- */
1240
- const stringDescriptor = (attrName) => ({
1241
- configurable: true,
1242
- enumerable: true,
1243
- get() {
1244
- return this.getAttribute(attrName);
1245
- },
1246
- set(newValue) {
1247
- const currentValue = this.getAttribute(attrName);
1248
- const normalizedValue = String(newValue);
1249
- if (normalizedValue !== currentValue) {
1250
- this.setAttribute(attrName, normalizedValue);
1251
- }
1252
- },
1253
- });
1254
- /** Descriptor for a boolean that checks for `attr="true"` or `attr="false"`, e.g. `spellcheck` and `draggable`. */
1255
- const explicitBooleanDescriptor = (attrName, defaultValue) => ({
1256
- configurable: true,
1257
- enumerable: true,
1258
- get() {
1259
- const value = this.getAttribute(attrName);
1260
- if (value === null)
1261
- return defaultValue;
1262
- // spellcheck=false => false, everything else => true
1263
- // draggable=true => true, everything else => false
1264
- return value.toLowerCase() === String(defaultValue) ? defaultValue : !defaultValue;
1265
- },
1266
- set(newValue) {
1267
- const currentValue = this.getAttribute(attrName);
1268
- const normalizedValue = String(Boolean(newValue));
1269
- if (normalizedValue !== currentValue) {
1270
- this.setAttribute(attrName, normalizedValue);
1271
- }
1272
- },
1273
- });
1274
- /**
1275
- * Descriptor for a "true" boolean attribute that checks solely for presence, e.g. `hidden`.
1276
- */
1277
- const booleanAttributeDescriptor = (attrName) => ({
1278
- configurable: true,
1279
- enumerable: true,
1280
- get() {
1281
- return this.hasAttribute(attrName);
1282
- },
1283
- set(newValue) {
1284
- const hasAttribute = this.hasAttribute(attrName);
1285
- if (newValue) {
1286
- if (!hasAttribute) {
1287
- this.setAttribute(attrName, '');
1288
- }
1289
- }
1290
- else {
1291
- if (hasAttribute) {
1292
- this.removeAttribute(attrName);
1293
- }
1294
- }
1295
- },
1296
- });
1297
- /**
1298
- * Descriptor for ARIA reflections, e.g. `ariaLabel` and `role`.
1299
- */
1300
- const ariaDescriptor = (attrName) => ({
1301
- configurable: true,
1302
- enumerable: true,
1303
- get() {
1304
- return this.getAttribute(attrName);
1305
- },
1306
- set(newValue) {
1307
- const currentValue = this.getAttribute(attrName);
1308
- if (newValue !== currentValue) {
1309
- // TODO [#3284]: According to the spec, IDL nullable type values
1310
- // (null and undefined) should remove the attribute; however, we
1311
- // only do so in the case of null for historical reasons.
1312
- if (isNull(newValue)) {
1313
- this.removeAttribute(attrName);
1314
- }
1315
- else {
1316
- this.setAttribute(attrName, toString(newValue));
1317
- }
1318
- }
1319
- },
1320
- });
1321
- const tabIndexDescriptor = () => ({
1322
- configurable: true,
1323
- enumerable: true,
1324
- get() {
1325
- const str = this.getAttribute('tabindex');
1326
- const num = Number(str);
1327
- return isFinite(num) ? Math.trunc(num) : -1;
1328
- },
1329
- set(newValue) {
1330
- const currentValue = this.getAttribute('tabindex');
1331
- const num = Number(newValue);
1332
- const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
1333
- if (normalizedValue !== currentValue) {
1334
- this.setAttribute('tabindex', toString(newValue));
1335
- }
1336
- },
1337
- });
1338
- const descriptors = {
1339
- accessKey: stringDescriptor('accesskey'),
1340
- dir: stringDescriptor('dir'),
1341
- draggable: explicitBooleanDescriptor('draggable', true),
1342
- hidden: booleanAttributeDescriptor('hidden'),
1343
- id: stringDescriptor('id'),
1344
- lang: stringDescriptor('lang'),
1345
- spellcheck: explicitBooleanDescriptor('spellcheck', false),
1346
- tabIndex: tabIndexDescriptor(),
1347
- title: stringDescriptor('title'),
1348
- };
1349
- // Add descriptors for ARIA attributes
1350
- for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {
1351
- descriptors[propName] = ariaDescriptor(attrName);
1352
- }
1353
-
1354
1313
  /*
1355
1314
  * Copyright (c) 2024, salesforce.com, inc.
1356
1315
  * All rights reserved.
1357
1316
  * SPDX-License-Identifier: MIT
1358
1317
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1359
1318
  */
1360
- var _LightningElement_attrs, _LightningElement_classList;
1319
+ var _LightningElement_props, _LightningElement_attrs, _LightningElement_classList;
1361
1320
  const SYMBOL__SET_INTERNALS = Symbol('set-internals');
1362
1321
  const SYMBOL__GENERATE_MARKUP = Symbol('generate-markup');
1363
1322
  const SYMBOL__DEFAULT_TEMPLATE = Symbol('default-template');
1364
1323
  class LightningElement {
1365
1324
  constructor(propsAvailableAtConstruction) {
1366
1325
  this.isConnected = false;
1367
- this.className = '';
1368
- _LightningElement_attrs.set(this, void 0);
1326
+ _LightningElement_props.set(this, undefined);
1327
+ _LightningElement_attrs.set(this, undefined);
1369
1328
  _LightningElement_classList.set(this, null);
1370
1329
  assign(this, propsAvailableAtConstruction);
1371
1330
  }
1372
- [(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs) {
1331
+ [(_LightningElement_props = new WeakMap(), _LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs, publicProperties, privateProperties) {
1332
+ __classPrivateFieldSet(this, _LightningElement_props, props, "f");
1373
1333
  __classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
1374
- assign(this, props);
1375
- defineProperty(this, 'className', {
1376
- get() {
1377
- return props.class ?? '';
1378
- },
1379
- set(newVal) {
1380
- props.class = newVal;
1381
- attrs.class = newVal;
1382
- mutationTracker.add(this, 'class');
1383
- },
1384
- });
1334
+ // Avoid setting the following types of properties that should not be set:
1335
+ // - Properties that are not public.
1336
+ // - Properties that are not global.
1337
+ // - Properties that are global but are internally overridden.
1338
+ for (const propName of keys(props)) {
1339
+ const attrName = htmlPropertyToAttribute(propName);
1340
+ if (publicProperties.has(propName) ||
1341
+ ((REFLECTIVE_GLOBAL_PROPERTY_SET.has(propName) || isAriaAttribute(attrName)) &&
1342
+ !privateProperties.has(propName))) {
1343
+ // For props passed from parents to children, they are intended to be read-only
1344
+ // to avoid a child mutating its parent's state
1345
+ this[propName] = getReadOnlyProxy(props[propName]);
1346
+ }
1347
+ }
1348
+ }
1349
+ get className() {
1350
+ return __classPrivateFieldGet(this, _LightningElement_props, "f").class ?? '';
1351
+ }
1352
+ set className(newVal) {
1353
+ __classPrivateFieldGet(this, _LightningElement_props, "f").class = newVal;
1354
+ __classPrivateFieldGet(this, _LightningElement_attrs, "f").class = newVal;
1355
+ mutationTracker.add(this, 'class');
1385
1356
  }
1386
1357
  get classList() {
1387
1358
  if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
@@ -1494,7 +1465,6 @@ defineProperties(LightningElement.prototype, descriptors);
1494
1465
  * SPDX-License-Identifier: MIT
1495
1466
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1496
1467
  */
1497
- const escapeAttrVal = (attrValue) => attrValue.replaceAll('&', '&').replaceAll('"', '"');
1498
1468
  function renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken) {
1499
1469
  // The scopeToken is e.g. `lwc-xyz123` which is the token our parent gives us.
1500
1470
  // The hostScopeToken is e.g. `lwc-abc456-host` which is the token for our own component.
@@ -1528,7 +1498,8 @@ function renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken) {
1528
1498
  hasClassAttribute = true;
1529
1499
  }
1530
1500
  }
1531
- result += attrValue === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrValue)}"`;
1501
+ result +=
1502
+ attrValue === '' ? ` ${attrName}` : ` ${attrName}="${htmlEscape(attrValue, true)}"`;
1532
1503
  }
1533
1504
  // If we didn't render any `class` attribute, render one for the scope token(s)
1534
1505
  if (!hasClassAttribute && combinedScopeToken) {
@@ -1547,14 +1518,20 @@ function* renderAttrs(instance, attrs, hostScopeToken, scopeToken) {
1547
1518
  function renderAttrsNoYield(emit, instance, attrs, hostScopeToken, scopeToken) {
1548
1519
  emit(renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken));
1549
1520
  }
1550
- function* fallbackTmpl(_props, _attrs, _shadowSlottedContent, _lightSlottedContent, Cmp, _instance) {
1521
+ function* fallbackTmpl(shadowSlottedContent, _lightSlottedContent, _scopedSlottedContent, Cmp, instance) {
1551
1522
  if (Cmp.renderMode !== 'light') {
1552
- yield '<template shadowrootmode="open"></template>';
1523
+ yield `<template shadowrootmode="open"></template>`;
1524
+ if (shadowSlottedContent) {
1525
+ yield shadowSlottedContent(instance);
1526
+ }
1553
1527
  }
1554
1528
  }
1555
- function fallbackTmplNoYield(emit, _props, _attrs, _shadowSlottedContent, _lightSlottedContent, Cmp, _instance) {
1529
+ function fallbackTmplNoYield(emit, shadowSlottedContent, _lightSlottedContent, _scopedSlottedContent, Cmp, instance) {
1556
1530
  if (Cmp.renderMode !== 'light') {
1557
- emit('<template shadowrootmode="open"></template>');
1531
+ emit(`<template shadowrootmode="open"></template>`);
1532
+ if (shadowSlottedContent) {
1533
+ shadowSlottedContent(emit, instance);
1534
+ }
1558
1535
  }
1559
1536
  }
1560
1537
  async function serverSideRenderComponent(tagName, Component, props = {}, mode = DEFAULT_SSR_MODE) {
@@ -1566,16 +1543,23 @@ async function serverSideRenderComponent(tagName, Component, props = {}, mode =
1566
1543
  const emit = (segment) => {
1567
1544
  markup += segment;
1568
1545
  };
1546
+ if (!generateMarkup) {
1547
+ // If a non-component is accidentally provided, render an empty template
1548
+ emit(`<${tagName}>`);
1549
+ fallbackTmplNoYield(emit, null, null, null, Component, null);
1550
+ emit(`</${tagName}>`);
1551
+ return markup;
1552
+ }
1569
1553
  if (mode === 'asyncYield') {
1570
- for await (const segment of generateMarkup(tagName, props, null, null, null, null, null, null)) {
1554
+ for await (const segment of generateMarkup(tagName, props, null, null, null, null, null, null, null)) {
1571
1555
  markup += segment;
1572
1556
  }
1573
1557
  }
1574
1558
  else if (mode === 'async') {
1575
- await generateMarkup(emit, tagName, props, null, null, null, null, null, null);
1559
+ await generateMarkup(emit, tagName, props, null, null, null, null, null, null, null);
1576
1560
  }
1577
1561
  else if (mode === 'sync') {
1578
- generateMarkup(emit, tagName, props, null, null, null, null, null, null);
1562
+ generateMarkup(emit, tagName, props, null, null, null, null, null, null, null);
1579
1563
  }
1580
1564
  else {
1581
1565
  throw new Error(`Invalid mode: ${mode}`);
@@ -1590,14 +1574,27 @@ async function serverSideRenderComponent(tagName, Component, props = {}, mode =
1590
1574
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1591
1575
  */
1592
1576
  /**
1593
- * Given an object, render it for use as a text content node.
1577
+ * Given an object, render it for use as a text content node. Not that this applies to individual text nodes,
1578
+ * not the concatenated result of multiple adjacent text nodes.
1594
1579
  * @param value
1595
1580
  */
1596
- function massageTextContent(value) {
1581
+ function normalizeTextContent(value) {
1597
1582
  // Using non strict equality to align with original implementation (ex. undefined == null)
1598
1583
  // See: https://github.com/salesforce/lwc/blob/348130f/packages/%40lwc/engine-core/src/framework/api.ts#L548
1599
1584
  return value == null ? '' : String(value);
1600
1585
  }
1586
+ /**
1587
+ * Given a string, render it for use as text content in HTML. Notably this escapes HTML and renders as
1588
+ * a ZWJ is empty. Intended to be used on the result of concatenating multiple adjacent text nodes together.
1589
+ * @param value
1590
+ */
1591
+ function renderTextContent(value) {
1592
+ // We are at the end of a series of text nodes - flush to a concatenated string
1593
+ // We only render the ZWJ if there were actually any dynamic text nodes rendered
1594
+ // The ZWJ is just so hydration can compare the SSR'd dynamic text content against
1595
+ // the CSR'd text content.
1596
+ return value === '' ? '\u200D' : htmlEscape(value);
1597
+ }
1601
1598
 
1602
1599
  /*
1603
1600
  * Copyright (c) 2024, Salesforce, Inc.
@@ -1785,6 +1782,6 @@ function createContextProvider(adapter) {
1785
1782
  };
1786
1783
  }
1787
1784
 
1788
- export { ClassList, LightningElement, SYMBOL__DEFAULT_TEMPLATE, SYMBOL__GENERATE_MARKUP, SYMBOL__SET_INTERNALS, api, connectContext, createContextProvider, createElement, establishContextfulRelationship, fallbackTmpl, fallbackTmplNoYield, filterProperties, freezeTemplate, getComponentDef, getReadOnlyProxy, hasScopedStaticStylesheets, hot, htmlEscape, isComponentConstructor, massageTextContent, mutationTracker, normalizeClass, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, renderAttrs, renderAttrsNoYield, serverSideRenderComponent as renderComponent, renderStylesheets, renderer, sanitizeAttribute, sanitizeHtmlContent, serverSideRenderComponent, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, toIteratorDirective, track, unwrap$1 as unwrap, validateStyleTextContents, wire };
1789
- /** version: 8.12.2 */
1785
+ 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 };
1786
+ /** version: 8.13.0 */
1790
1787
  //# sourceMappingURL=index.js.map