@lwc/ssr-runtime 8.3.0 → 8.5.0

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