@lwc/ssr-runtime 8.12.1 → 8.12.2

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.cjs.js CHANGED
@@ -461,43 +461,6 @@ const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (
461
461
  function isAriaAttribute(attrName) {
462
462
  return attrName in AriaAttrNameToPropNameMap;
463
463
  }
464
- // This list is based on https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
465
- const GLOBAL_ATTRIBUTE = /*@__PURE__*/ new Set([
466
- 'accesskey',
467
- 'autocapitalize',
468
- 'autofocus',
469
- 'class',
470
- 'contenteditable',
471
- 'dir',
472
- 'draggable',
473
- 'enterkeyhint',
474
- 'exportparts',
475
- 'hidden',
476
- 'id',
477
- 'inputmode',
478
- 'is',
479
- 'itemid',
480
- 'itemprop',
481
- 'itemref',
482
- 'itemscope',
483
- 'itemtype',
484
- 'lang',
485
- 'nonce',
486
- 'part',
487
- 'slot',
488
- 'spellcheck',
489
- 'style',
490
- 'tabindex',
491
- 'title',
492
- 'translate',
493
- ]);
494
- /**
495
- *
496
- * @param attrName
497
- */
498
- function isGlobalHtmlAttribute(attrName) {
499
- return GLOBAL_ATTRIBUTE.has(attrName);
500
- }
501
464
  // These are HTML standard prop/attribute IDL mappings, but are not predictable based on camel/kebab-case conversion
502
465
  const SPECIAL_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map([
503
466
  ['accessKey', 'accesskey'],
@@ -517,6 +480,21 @@ const SPECIAL_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map([
517
480
  ['useMap', 'usemap'],
518
481
  ['htmlFor', 'for'],
519
482
  ]);
483
+ // Global properties that this framework currently reflects. For CSR, the native
484
+ // descriptors for these properties are added from HTMLElement.prototype to
485
+ // LightningElement.prototype. For SSR, in order to match CSR behavior, this
486
+ // list is used to determine which attributes to reflect.
487
+ const REFLECTIVE_GLOBAL_PROPERTY_SET = /*@__PURE__@*/ new Set([
488
+ 'accessKey',
489
+ 'dir',
490
+ 'draggable',
491
+ 'hidden',
492
+ 'id',
493
+ 'lang',
494
+ 'spellcheck',
495
+ 'tabIndex',
496
+ 'title',
497
+ ]);
520
498
  /**
521
499
  * Map associating previously transformed HTML property into HTML attribute.
522
500
  */
@@ -653,7 +631,7 @@ function setHooks(hooks) {
653
631
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
654
632
  */
655
633
  const DEFAULT_SSR_MODE = 'sync';
656
- /** version: 8.12.1 */
634
+ /** version: 8.12.2 */
657
635
 
658
636
  /*
659
637
  * Copyright (c) 2024, Salesforce, Inc.
@@ -1253,7 +1231,7 @@ function filterProperties(props, publicFields, privateFields) {
1253
1231
  keys(props).forEach((propName) => {
1254
1232
  const attrName = htmlPropertyToAttribute(propName);
1255
1233
  if (publicFieldSet.has(propName) ||
1256
- ((isGlobalHtmlAttribute(attrName) || isAriaAttribute(attrName)) &&
1234
+ ((REFLECTIVE_GLOBAL_PROPERTY_SET.has(propName) || isAriaAttribute(attrName)) &&
1257
1235
  !privateFieldSet.has(propName))) {
1258
1236
  propsToAssign[propName] = props[propName];
1259
1237
  }
@@ -1532,6 +1510,12 @@ function renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken) {
1532
1510
  let hasClassAttribute = false;
1533
1511
  for (const attrName of getOwnPropertyNames$1(attrs)) {
1534
1512
  let attrValue = attrs[attrName];
1513
+ // Backwards compatibility with historical patchStyleAttribute() behavior:
1514
+ // https://github.com/salesforce/lwc/blob/59e2c6c/packages/%40lwc/engine-core/src/framework/modules/computed-style-attr.ts#L40
1515
+ if (attrName === 'style' && (!isString(attrValue) || attrValue === '')) {
1516
+ // If the style attribute is invalid, we don't render it.
1517
+ continue;
1518
+ }
1535
1519
  if (isNull(attrValue) || isUndefined$1(attrValue)) {
1536
1520
  attrValue = '';
1537
1521
  }
@@ -1852,5 +1836,5 @@ exports.track = track;
1852
1836
  exports.unwrap = unwrap$1;
1853
1837
  exports.validateStyleTextContents = validateStyleTextContents;
1854
1838
  exports.wire = wire;
1855
- /** version: 8.12.1 */
1839
+ /** version: 8.12.2 */
1856
1840
  //# sourceMappingURL=index.cjs.js.map