@lwc/ssr-runtime 8.3.0 → 8.5.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
@@ -1,8 +1,6 @@
1
1
  /**
2
2
  * Copyright (c) 2024 Salesforce, Inc.
3
3
  */
4
- import { htmlPropertyToAttribute } from '@lwc/shared';
5
-
6
4
  /*
7
5
  * Copyright (c) 2024, Salesforce, Inc.
8
6
  * All rights reserved.
@@ -114,6 +112,238 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
114
112
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
115
113
  };
116
114
 
115
+ /**
116
+ * Copyright (c) 2024 Salesforce, Inc.
117
+ */
118
+ /*
119
+ * Copyright (c) 2018, salesforce.com, inc.
120
+ * All rights reserved.
121
+ * SPDX-License-Identifier: MIT
122
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
123
+ */
124
+ /**
125
+ *
126
+ * @param value
127
+ * @param msg
128
+ */
129
+
130
+ /*
131
+ * Copyright (c) 2024, Salesforce, Inc.
132
+ * All rights reserved.
133
+ * SPDX-License-Identifier: MIT
134
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
135
+ */
136
+ const {
137
+ /** Detached {@linkcode Object.assign}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign MDN Reference}. */
138
+ assign,
139
+ /** Detached {@linkcode Object.create}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create MDN Reference}. */
140
+ create,
141
+ /** Detached {@linkcode Object.defineProperties}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties MDN Reference}. */
142
+ defineProperties,
143
+ /** Detached {@linkcode Object.defineProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty MDN Reference}. */
144
+ defineProperty,
145
+ /** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
146
+ entries,
147
+ /** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
148
+ freeze,
149
+ /** Detached {@linkcode Object.fromEntries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries MDN Reference}. */
150
+ fromEntries,
151
+ /** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
152
+ getOwnPropertyDescriptor,
153
+ /** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
154
+ getOwnPropertyDescriptors,
155
+ /** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
156
+ getOwnPropertyNames,
157
+ /** Detached {@linkcode Object.getOwnPropertySymbols}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols MDN Reference}. */
158
+ getOwnPropertySymbols,
159
+ /** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
160
+ getPrototypeOf,
161
+ /** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
162
+ hasOwnProperty,
163
+ /** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
164
+ isFrozen,
165
+ /** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
166
+ keys,
167
+ /** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */
168
+ seal,
169
+ /** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
170
+ setPrototypeOf, } = Object;
171
+ const {
172
+ /** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
173
+ isArray,
174
+ /** Detached {@linkcode Array.from}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from MDN Reference}. */
175
+ from: ArrayFrom, } = Array;
176
+ // For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
177
+ // though it works fine for one, e.g. isArray), so comments for these are added to the export
178
+ // statement, rather than this declaration.
179
+ const { concat: ArrayConcat, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, // Weird anomaly!
180
+ } = Array.prototype;
181
+ // No JSDocs here - see comment for Array.prototype
182
+ const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
183
+ /**
184
+ * Determines whether the argument is `null`.
185
+ * @param obj Value to test
186
+ * @returns `true` if the value is `null`.
187
+ */
188
+ function isNull(obj) {
189
+ return obj === null;
190
+ }
191
+ const OtS = {}.toString;
192
+ /**
193
+ * Converts the argument to a string, safely accounting for objects with "null" prototype.
194
+ * Note that `toString(null)` returns `"[object Null]"` rather than `"null"`.
195
+ * @param obj Value to convert to a string.
196
+ * @returns String representation of the value.
197
+ */
198
+ function toString(obj) {
199
+ if (obj?.toString) {
200
+ // Arrays might hold objects with "null" prototype So using
201
+ // Array.prototype.toString directly will cause an error Iterate through
202
+ // all the items and handle individually.
203
+ if (isArray(obj)) {
204
+ // This behavior is slightly different from Array#toString:
205
+ // 1. Array#toString calls `this.join`, rather than Array#join
206
+ // Ex: arr = []; arr.join = () => 1; arr.toString() === 1; toString(arr) === ''
207
+ // 2. Array#toString delegates to Object#toString if `this.join` is not a function
208
+ // Ex: arr = []; arr.join = 'no'; arr.toString() === '[object Array]; toString(arr) = ''
209
+ // 3. Array#toString converts null/undefined to ''
210
+ // Ex: arr = [null, undefined]; arr.toString() === ','; toString(arr) === '[object Null],undefined'
211
+ // 4. Array#toString converts recursive references to arrays to ''
212
+ // Ex: arr = [1]; arr.push(arr, 2); arr.toString() === '1,,2'; toString(arr) throws
213
+ // Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
214
+ return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
215
+ }
216
+ return obj.toString();
217
+ }
218
+ else if (typeof obj === 'object') {
219
+ // This catches null and returns "[object Null]". Weird, but kept for backwards compatibility.
220
+ return OtS.call(obj);
221
+ }
222
+ else {
223
+ return String(obj);
224
+ }
225
+ }
226
+
227
+ /*
228
+ * Copyright (c) 2018, salesforce.com, inc.
229
+ * All rights reserved.
230
+ * SPDX-License-Identifier: MIT
231
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
232
+ */
233
+ /**
234
+ * According to the following list, there are 48 aria attributes of which two (ariaDropEffect and
235
+ * ariaGrabbed) are deprecated:
236
+ * https://www.w3.org/TR/wai-aria-1.1/#x6-6-definitions-of-states-and-properties-all-aria-attributes
237
+ *
238
+ * The above list of 46 aria attributes is consistent with the following resources:
239
+ * https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
240
+ * https://wicg.github.io/aom/spec/aria-reflection.html
241
+ *
242
+ * NOTE: If you update this list, please update test files that implicitly reference this list!
243
+ * Searching the codebase for `aria-flowto` and `ariaFlowTo` should be good enough to find all usages.
244
+ */
245
+ const AriaPropertyNames = [
246
+ 'ariaActiveDescendant',
247
+ 'ariaAtomic',
248
+ 'ariaAutoComplete',
249
+ 'ariaBusy',
250
+ 'ariaChecked',
251
+ 'ariaColCount',
252
+ 'ariaColIndex',
253
+ 'ariaColIndexText',
254
+ 'ariaColSpan',
255
+ 'ariaControls',
256
+ 'ariaCurrent',
257
+ 'ariaDescribedBy',
258
+ 'ariaDescription',
259
+ 'ariaDetails',
260
+ 'ariaDisabled',
261
+ 'ariaErrorMessage',
262
+ 'ariaExpanded',
263
+ 'ariaFlowTo',
264
+ 'ariaHasPopup',
265
+ 'ariaHidden',
266
+ 'ariaInvalid',
267
+ 'ariaKeyShortcuts',
268
+ 'ariaLabel',
269
+ 'ariaLabelledBy',
270
+ 'ariaLevel',
271
+ 'ariaLive',
272
+ 'ariaModal',
273
+ 'ariaMultiLine',
274
+ 'ariaMultiSelectable',
275
+ 'ariaOrientation',
276
+ 'ariaOwns',
277
+ 'ariaPlaceholder',
278
+ 'ariaPosInSet',
279
+ 'ariaPressed',
280
+ 'ariaReadOnly',
281
+ 'ariaRelevant',
282
+ 'ariaRequired',
283
+ 'ariaRoleDescription',
284
+ 'ariaRowCount',
285
+ 'ariaRowIndex',
286
+ 'ariaRowIndexText',
287
+ 'ariaRowSpan',
288
+ 'ariaSelected',
289
+ 'ariaSetSize',
290
+ 'ariaSort',
291
+ 'ariaValueMax',
292
+ 'ariaValueMin',
293
+ 'ariaValueNow',
294
+ 'ariaValueText',
295
+ 'ariaBrailleLabel',
296
+ 'ariaBrailleRoleDescription',
297
+ 'role',
298
+ ];
299
+ const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (() => {
300
+ const AriaAttrNameToPropNameMap = create(null);
301
+ const AriaPropNameToAttrNameMap = create(null);
302
+ // Synthetic creation of all AOM property descriptors for Custom Elements
303
+ forEach.call(AriaPropertyNames, (propName) => {
304
+ const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-'));
305
+ AriaAttrNameToPropNameMap[attrName] = propName;
306
+ AriaPropNameToAttrNameMap[propName] = attrName;
307
+ });
308
+ return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap };
309
+ })();
310
+
311
+ /*
312
+ * Copyright (c) 2020, salesforce.com, inc.
313
+ * All rights reserved.
314
+ * SPDX-License-Identifier: MIT
315
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
316
+ */
317
+ const ESCAPED_CHARS = {
318
+ '"': '"',
319
+ "'": ''',
320
+ '<': '&lt;',
321
+ '>': '&gt;',
322
+ '&': '&amp;',
323
+ };
324
+ /**
325
+ *
326
+ * @param str
327
+ * @param attrMode
328
+ */
329
+ function htmlEscape(str, attrMode = false) {
330
+ const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
331
+ return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
332
+ }
333
+ function flattenStylesheets(stylesheets) {
334
+ const list = [];
335
+ for (const stylesheet of stylesheets) {
336
+ if (!isArray(stylesheet)) {
337
+ list.push(stylesheet);
338
+ }
339
+ else {
340
+ list.push(...flattenStylesheets(stylesheet));
341
+ }
342
+ }
343
+ return list;
344
+ }
345
+ /** version: 8.5.0 */
346
+
117
347
  /*
118
348
  * Copyright (c) 2024, Salesforce, Inc.
119
349
  * All rights reserved.
@@ -155,41 +385,169 @@ class MutationTracker {
155
385
  _MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
156
386
  const mutationTracker = new MutationTracker();
157
387
 
388
+ /*
389
+ * Copyright (c) 2024, Salesforce, Inc.
390
+ * All rights reserved.
391
+ * SPDX-License-Identifier: MIT
392
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
393
+ */
394
+ /**
395
+ * Map of global attribute or ARIA attribute to the corresponding property name.
396
+ * Not all global attributes are included, just those from `HTMLElementTheGoodParts`.
397
+ */
398
+ const attrsToProps = assign(create(null), {
399
+ accesskey: 'accessKey',
400
+ dir: 'dir',
401
+ draggable: 'draggable',
402
+ hidden: 'hidden',
403
+ id: 'id',
404
+ lang: 'lang',
405
+ spellcheck: 'spellcheck',
406
+ tabindex: 'tabIndex',
407
+ title: 'title',
408
+ ...AriaAttrNameToPropNameMap,
409
+ });
410
+ /**
411
+ * Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
412
+ */
413
+ const stringDescriptor = (attrName) => ({
414
+ configurable: true,
415
+ enumerable: true,
416
+ get() {
417
+ return this.getAttribute(attrName);
418
+ },
419
+ set(newValue) {
420
+ const currentValue = this.getAttribute(attrName);
421
+ const normalizedValue = String(newValue);
422
+ if (normalizedValue !== currentValue) {
423
+ this.setAttribute(attrName, normalizedValue);
424
+ }
425
+ },
426
+ });
427
+ /** Descriptor for a boolean that checks for `attr="true"` or `attr="false"`, e.g. `spellcheck` and `draggable`. */
428
+ const explicitBooleanDescriptor = (attrName, defaultValue) => ({
429
+ configurable: true,
430
+ enumerable: true,
431
+ get() {
432
+ const value = this.getAttribute(attrName);
433
+ return value === null ? defaultValue : value === String(defaultValue);
434
+ },
435
+ set(newValue) {
436
+ const currentValue = this.getAttribute(attrName);
437
+ const normalizedValue = String(Boolean(newValue));
438
+ if (normalizedValue !== currentValue) {
439
+ this.setAttribute(attrName, normalizedValue);
440
+ }
441
+ },
442
+ });
443
+ /**
444
+ * Descriptor for a "true" boolean attribute that checks solely for presence, e.g. `hidden`.
445
+ */
446
+ const booleanAttributeDescriptor = (attrName) => ({
447
+ configurable: true,
448
+ enumerable: true,
449
+ get() {
450
+ return this.hasAttribute(attrName);
451
+ },
452
+ set(newValue) {
453
+ const hasAttribute = this.hasAttribute(attrName);
454
+ if (newValue) {
455
+ if (!hasAttribute) {
456
+ this.setAttribute(attrName, '');
457
+ }
458
+ }
459
+ else {
460
+ if (hasAttribute) {
461
+ this.removeAttribute(attrName);
462
+ }
463
+ }
464
+ },
465
+ });
466
+ /**
467
+ * Descriptor for ARIA reflections, e.g. `ariaLabel` and `role`.
468
+ */
469
+ const ariaDescriptor = (attrName) => ({
470
+ configurable: true,
471
+ enumerable: true,
472
+ get() {
473
+ return this.getAttribute(attrName);
474
+ },
475
+ set(newValue) {
476
+ const currentValue = this.getAttribute(attrName);
477
+ if (newValue !== currentValue) {
478
+ // TODO [#3284]: According to the spec, IDL nullable type values
479
+ // (null and undefined) should remove the attribute; however, we
480
+ // only do so in the case of null for historical reasons.
481
+ if (isNull(newValue)) {
482
+ this.removeAttribute(attrName);
483
+ }
484
+ else {
485
+ this.setAttribute(attrName, toString(newValue));
486
+ }
487
+ }
488
+ },
489
+ });
490
+ function reflectAttrToProp(instance, attrName, attrValue) {
491
+ const reflectedPropName = attrsToProps[attrName];
492
+ // If it is a reflected property and it was not overridden by the instance
493
+ if (reflectedPropName && !hasOwnProperty.call(instance, reflectedPropName)) {
494
+ const currentValue = instance[reflectedPropName];
495
+ if (currentValue !== attrValue) {
496
+ instance[reflectedPropName] = attrValue;
497
+ }
498
+ }
499
+ }
500
+ const descriptors = {
501
+ accessKey: stringDescriptor('accesskey'),
502
+ dir: stringDescriptor('dir'),
503
+ draggable: explicitBooleanDescriptor('draggable', true),
504
+ hidden: booleanAttributeDescriptor('hidden'),
505
+ id: stringDescriptor('id'),
506
+ lang: stringDescriptor('lang'),
507
+ spellcheck: explicitBooleanDescriptor('spellcheck', false),
508
+ tabIndex: {
509
+ get() {
510
+ const str = this.getAttribute('tabindex');
511
+ const num = Number(str);
512
+ return isFinite(num) ? Math.trunc(num) : -1;
513
+ },
514
+ set(newValue) {
515
+ const currentValue = this.getAttribute('tabindex');
516
+ const num = Number(newValue);
517
+ const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
518
+ if (normalizedValue !== currentValue) {
519
+ this.setAttribute('tabindex', toString(newValue));
520
+ }
521
+ },
522
+ },
523
+ title: stringDescriptor('title'),
524
+ };
525
+ // Add descriptors for ARIA attributes
526
+ for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {
527
+ descriptors[propName] = ariaDescriptor(attrName);
528
+ }
529
+
158
530
  /*
159
531
  * Copyright (c) 2024, salesforce.com, inc.
160
532
  * All rights reserved.
161
533
  * SPDX-License-Identifier: MIT
162
534
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
163
535
  */
164
- var _LightningElement_instances, _LightningElement_attrs, _LightningElement_classList, _LightningElement_setAttribute;
536
+ var _LightningElement_attrs, _LightningElement_classList;
165
537
  const SYMBOL__SET_INTERNALS = Symbol('set-internals');
538
+ const SYMBOL__GENERATE_MARKUP = Symbol('generate-markup');
166
539
  class LightningElement {
167
540
  constructor(propsAvailableAtConstruction) {
168
- _LightningElement_instances.add(this);
169
541
  this.isConnected = false;
170
542
  this.className = '';
171
543
  _LightningElement_attrs.set(this, void 0);
172
544
  _LightningElement_classList.set(this, null);
173
- Object.assign(this, propsAvailableAtConstruction);
545
+ assign(this, propsAvailableAtConstruction);
174
546
  }
175
- [(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), _LightningElement_instances = new WeakSet(), SYMBOL__SET_INTERNALS)](props, reflectedProps, attrs) {
176
- Object.assign(this, props);
547
+ [(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs) {
177
548
  __classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
178
- // Whenever a reflected prop changes, we'll update the original props object
179
- // that was passed in. That'll be referenced when the attrs are rendered later.
180
- for (const reflectedPropName of reflectedProps) {
181
- Object.defineProperty(this, reflectedPropName, {
182
- get() {
183
- return props[reflectedPropName] ?? null;
184
- },
185
- set(newValue) {
186
- props[reflectedPropName] = newValue;
187
- mutationTracker.add(this, htmlPropertyToAttribute(reflectedPropName));
188
- },
189
- enumerable: true,
190
- });
191
- }
192
- Object.defineProperty(this, 'className', {
549
+ assign(this, props);
550
+ defineProperty(this, 'className', {
193
551
  get() {
194
552
  return props.class ?? '';
195
553
  },
@@ -207,29 +565,29 @@ class LightningElement {
207
565
  return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
208
566
  }
209
567
  setAttribute(attrName, attrValue) {
210
- __classPrivateFieldGet(this, _LightningElement_instances, "m", _LightningElement_setAttribute).call(this, attrName, String(attrValue));
568
+ const normalizedName = StringToLowerCase.call(toString(attrName));
569
+ const normalizedValue = String(attrValue);
570
+ __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
571
+ reflectAttrToProp(this, normalizedName, normalizedValue);
572
+ mutationTracker.add(this, normalizedName);
211
573
  }
212
574
  getAttribute(attrName) {
213
- if (this.hasAttribute(attrName)) {
214
- return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[attrName];
575
+ const normalizedName = StringToLowerCase.call(toString(attrName));
576
+ if (hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
577
+ return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
215
578
  }
216
579
  return null;
217
580
  }
218
581
  hasAttribute(attrName) {
219
- return typeof attrName === 'string' && typeof __classPrivateFieldGet(this, _LightningElement_attrs, "f")[attrName] === 'string';
582
+ const normalizedName = StringToLowerCase.call(toString(attrName));
583
+ return hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
220
584
  }
221
585
  removeAttribute(attrName) {
222
- if (this.hasAttribute(attrName)) {
223
- // Reflected attributes use accessor methods to update their
224
- // corresponding properties so we can't simply `delete`. Instead,
225
- // we use `null` when we want to remove.
226
- __classPrivateFieldGet(this, _LightningElement_instances, "m", _LightningElement_setAttribute).call(this, attrName, null);
227
- }
228
- else {
229
- // This interprets the removal of a non-existing attribute as an
230
- // attribute mutation. We may want to revisit this.
231
- mutationTracker.add(this, attrName);
232
- }
586
+ const normalizedName = StringToLowerCase.call(toString(attrName));
587
+ delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
588
+ reflectAttrToProp(this, normalizedName, null);
589
+ // Track mutations for removal of non-existing attributes
590
+ mutationTracker.add(this, normalizedName);
233
591
  }
234
592
  addEventListener(_type, _listener, _options) {
235
593
  // noop
@@ -305,10 +663,7 @@ class LightningElement {
305
663
  throw new Error('Method "setAttributeNS" not implemented.');
306
664
  }
307
665
  }
308
- _LightningElement_setAttribute = function _LightningElement_setAttribute(attrName, attrValue) {
309
- __classPrivateFieldGet(this, _LightningElement_attrs, "f")[attrName] = attrValue;
310
- mutationTracker.add(this, attrName);
311
- };
666
+ defineProperties(LightningElement.prototype, descriptors);
312
667
 
313
668
  /*
314
669
  * Copyright (c) 2024, salesforce.com, inc.
@@ -332,15 +687,54 @@ function* renderAttrs(instance, attrs) {
332
687
  }
333
688
  yield mutationTracker.renderMutatedAttrs(instance);
334
689
  }
690
+ function renderAttrsNoYield(emit, instance, attrs) {
691
+ if (!attrs) {
692
+ return;
693
+ }
694
+ for (const attrName of Object.getOwnPropertyNames(attrs)) {
695
+ const attrVal = attrs[attrName];
696
+ if (typeof attrVal === 'string') {
697
+ emit(attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`);
698
+ }
699
+ else if (attrVal === null) {
700
+ emit('');
701
+ }
702
+ }
703
+ emit(mutationTracker.renderMutatedAttrs(instance));
704
+ }
335
705
  function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
336
706
  if (Cmp.renderMode !== 'light') {
337
707
  yield '<template shadowrootmode="open"></template>';
338
708
  }
339
709
  }
340
- async function serverSideRenderComponent(tagName, compiledGenerateMarkup, props) {
710
+ function fallbackTmplNoYield(emit, _props, _attrs, _slotted, Cmp, _instance) {
711
+ if (Cmp.renderMode !== 'light') {
712
+ emit('<template shadowrootmode="open"></template>');
713
+ }
714
+ }
715
+ async function serverSideRenderComponent(tagName, Component, props = {}, mode = 'asyncYield') {
716
+ if (typeof tagName !== 'string') {
717
+ throw new Error(`tagName must be a string, found: ${tagName}`);
718
+ }
719
+ // TODO [#4726]: remove `generateMarkup` export
720
+ const generateMarkup = SYMBOL__GENERATE_MARKUP in Component ? Component[SYMBOL__GENERATE_MARKUP] : Component;
341
721
  let markup = '';
342
- for await (const segment of compiledGenerateMarkup(tagName, props, null, null)) {
722
+ const emit = (segment) => {
343
723
  markup += segment;
724
+ };
725
+ if (mode === 'asyncYield') {
726
+ for await (const segment of generateMarkup(tagName, props, null, null)) {
727
+ markup += segment;
728
+ }
729
+ }
730
+ else if (mode === 'async') {
731
+ await generateMarkup(emit, tagName, props, null, null);
732
+ }
733
+ else if (mode === 'sync') {
734
+ generateMarkup(emit, tagName, props, null, null);
735
+ }
736
+ else {
737
+ throw new Error(`Invalid mode: ${mode}`);
344
738
  }
345
739
  return markup;
346
740
  }
@@ -651,6 +1045,36 @@ function validateStyleTextContents(contents) {
651
1045
  }
652
1046
  }
653
1047
 
654
- export { ClassList, LightningElement, SYMBOL__SET_INTERNALS, api, createContextProvider, createElement, fallbackTmpl, freezeTemplate, getComponentDef, hot, isComponentConstructor, mutationTracker, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, renderAttrs, serverSideRenderComponent as renderComponent, renderer, sanitizeAttribute, serverSideRenderComponent, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, toIteratorDirective, track, unwrap, validateStyleTextContents, wire };
655
- /** version: 8.3.0 */
1048
+ /*
1049
+ * Copyright (c) 2024, Salesforce, Inc.
1050
+ * All rights reserved.
1051
+ * SPDX-License-Identifier: MIT
1052
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1053
+ */
1054
+ function hasScopedStaticStylesheets(Component) {
1055
+ const { stylesheets } = Component;
1056
+ if (stylesheets) {
1057
+ return flattenStylesheets(stylesheets).some((stylesheet) => stylesheet.$scoped$);
1058
+ }
1059
+ return false;
1060
+ }
1061
+ function renderStylesheets(stylesheets, scopeToken, Component, hasScopedTemplateStyles) {
1062
+ const hasAnyScopedStyles = hasScopedTemplateStyles || hasScopedStaticStylesheets(Component);
1063
+ let result = '';
1064
+ const truthyStylesheets = stylesheets.filter(Boolean);
1065
+ for (const stylesheet of flattenStylesheets(truthyStylesheets)) {
1066
+ // TODO [#2869]: `<style>`s should not have scope token classes
1067
+ result += `<style${hasAnyScopedStyles ? ` class="${scopeToken}"` : ''} type="text/css">`;
1068
+ const token = stylesheet.$scoped$ ? scopeToken : undefined;
1069
+ const useActualHostSelector = !stylesheet.$scoped$ || Component.renderMode !== 'light';
1070
+ const useNativeDirPseudoclass = true;
1071
+ const styleContents = stylesheet(token, useActualHostSelector, useNativeDirPseudoclass);
1072
+ validateStyleTextContents(styleContents);
1073
+ result += styleContents + '</style>';
1074
+ }
1075
+ return result;
1076
+ }
1077
+
1078
+ export { ClassList, LightningElement, SYMBOL__GENERATE_MARKUP, SYMBOL__SET_INTERNALS, api, createContextProvider, createElement, fallbackTmpl, fallbackTmplNoYield, freezeTemplate, getComponentDef, hasScopedStaticStylesheets, hot, htmlEscape, isComponentConstructor, mutationTracker, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, renderAttrs, renderAttrsNoYield, serverSideRenderComponent as renderComponent, renderStylesheets, renderer, sanitizeAttribute, serverSideRenderComponent, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, toIteratorDirective, track, unwrap, validateStyleTextContents, wire };
1079
+ /** version: 8.5.0 */
656
1080
  //# sourceMappingURL=index.js.map