@lwc/shared 2.30.1 → 2.30.3

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
@@ -294,6 +294,7 @@ function isVoidElement(name, namespace) {
294
294
  * SPDX-License-Identifier: MIT
295
295
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
296
296
  */
297
+ const CAMEL_REGEX = /-([a-z])/g;
297
298
  /**
298
299
  * Maps boolean attribute name to supported tags: 'boolean attr name' => Set of allowed tag names
299
300
  * that supports them.
@@ -366,32 +367,49 @@ const GLOBAL_ATTRIBUTE = new Set([
366
367
  function isGlobalHtmlAttribute(attrName) {
367
368
  return GLOBAL_ATTRIBUTE.has(attrName);
368
369
  }
369
- /**
370
- * Map composed of properties to attributes not following the HTML property to attribute mapping
371
- * convention.
372
- */
373
- const NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING = new Map([
374
- ['accessKey', 'accesskey'],
375
- ['readOnly', 'readonly'],
376
- ['tabIndex', 'tabindex'],
377
- ['bgColor', 'bgcolor'],
378
- ['colSpan', 'colspan'],
379
- ['rowSpan', 'rowspan'],
380
- ['contentEditable', 'contenteditable'],
381
- ['crossOrigin', 'crossorigin'],
382
- ['dateTime', 'datetime'],
383
- ['formAction', 'formaction'],
384
- ['isMap', 'ismap'],
385
- ['maxLength', 'maxlength'],
386
- ['minLength', 'minlength'],
387
- ['noValidate', 'novalidate'],
388
- ['useMap', 'usemap'],
389
- ['htmlFor', 'for'],
390
- ]);
370
+ // Convoluted map generation so that @lwc/shared remains fully tree-shakable (verify-treeshakable)
371
+ const { NO_STANDARD_ATTRIBUTE_PROPERTY_MAPPING, NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING } =
372
+ /*#__PURE__*/ (() => {
373
+ /**
374
+ * Map composed of properties to attributes not following the HTML property to attribute mapping
375
+ * convention.
376
+ */
377
+ const NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING = new Map([
378
+ ['accessKey', 'accesskey'],
379
+ ['readOnly', 'readonly'],
380
+ ['tabIndex', 'tabindex'],
381
+ ['bgColor', 'bgcolor'],
382
+ ['colSpan', 'colspan'],
383
+ ['rowSpan', 'rowspan'],
384
+ ['contentEditable', 'contenteditable'],
385
+ ['crossOrigin', 'crossorigin'],
386
+ ['dateTime', 'datetime'],
387
+ ['formAction', 'formaction'],
388
+ ['isMap', 'ismap'],
389
+ ['maxLength', 'maxlength'],
390
+ ['minLength', 'minlength'],
391
+ ['noValidate', 'novalidate'],
392
+ ['useMap', 'usemap'],
393
+ ['htmlFor', 'for'],
394
+ ]);
395
+ /**
396
+ * Inverted map with attribute name key and property name value.
397
+ */
398
+ const NO_STANDARD_ATTRIBUTE_PROPERTY_MAPPING = new Map();
399
+ NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING.forEach((value, key) => NO_STANDARD_ATTRIBUTE_PROPERTY_MAPPING.set(value, key));
400
+ return {
401
+ NO_STANDARD_ATTRIBUTE_PROPERTY_MAPPING,
402
+ NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING,
403
+ };
404
+ })();
391
405
  /**
392
406
  * Map associating previously transformed HTML property into HTML attribute.
393
407
  */
394
408
  const CACHED_PROPERTY_ATTRIBUTE_MAPPING = new Map();
409
+ /**
410
+ * Map associating previously transformed HTML attribute into HTML property.
411
+ */
412
+ const CACHED_ATTRIBUTE_PROPERTY_MAPPING = new Map();
395
413
  function htmlPropertyToAttribute(propName) {
396
414
  const ariaAttributeName = AriaPropNameToAttrNameMap[propName];
397
415
  if (!isUndefined(ariaAttributeName)) {
@@ -420,6 +438,23 @@ function htmlPropertyToAttribute(propName) {
420
438
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
421
439
  return attributeName;
422
440
  }
441
+ function htmlAttributeToProperty(attrName) {
442
+ const ariaPropertyName = AriaAttrNameToPropNameMap[attrName];
443
+ if (!isUndefined(ariaPropertyName)) {
444
+ return ariaPropertyName;
445
+ }
446
+ const specialPropertyName = NO_STANDARD_ATTRIBUTE_PROPERTY_MAPPING.get(attrName);
447
+ if (!isUndefined(specialPropertyName)) {
448
+ return specialPropertyName;
449
+ }
450
+ const cachedPropertyName = CACHED_ATTRIBUTE_PROPERTY_MAPPING.get(attrName);
451
+ if (!isUndefined(cachedPropertyName)) {
452
+ return cachedPropertyName;
453
+ }
454
+ const propertyName = StringReplace.call(attrName, CAMEL_REGEX, (g) => g[1].toUpperCase());
455
+ CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
456
+ return propertyName;
457
+ }
423
458
 
424
459
  /*
425
460
  * Copyright (c) 2020, salesforce.com, inc.
@@ -456,7 +491,7 @@ const hasNativeSymbolSupport = /*@__PURE__*/ (() => Symbol('x').toString() === '
456
491
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
457
492
  */
458
493
  // Increment whenever the LWC template compiler changes
459
- const LWC_VERSION = "2.30.1";
494
+ const LWC_VERSION = "2.30.3";
460
495
  const LWC_VERSION_COMMENT = `LWC compiler v${LWC_VERSION}`;
461
496
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
462
497
 
@@ -516,6 +551,7 @@ exports.getPrototypeOf = getPrototypeOf;
516
551
  exports.globalThis = _globalThis;
517
552
  exports.hasNativeSymbolSupport = hasNativeSymbolSupport;
518
553
  exports.hasOwnProperty = hasOwnProperty;
554
+ exports.htmlAttributeToProperty = htmlAttributeToProperty;
519
555
  exports.htmlEscape = htmlEscape;
520
556
  exports.htmlPropertyToAttribute = htmlPropertyToAttribute;
521
557
  exports.isAriaAttribute = isAriaAttribute;
@@ -538,4 +574,4 @@ exports.noop = noop;
538
574
  exports.seal = seal;
539
575
  exports.setPrototypeOf = setPrototypeOf;
540
576
  exports.toString = toString;
541
- /** version: 2.30.1 */
577
+ /** version: 2.30.3 */
package/dist/index.js CHANGED
@@ -292,6 +292,7 @@ function isVoidElement(name, namespace) {
292
292
  * SPDX-License-Identifier: MIT
293
293
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
294
294
  */
295
+ const CAMEL_REGEX = /-([a-z])/g;
295
296
  /**
296
297
  * Maps boolean attribute name to supported tags: 'boolean attr name' => Set of allowed tag names
297
298
  * that supports them.
@@ -364,32 +365,49 @@ const GLOBAL_ATTRIBUTE = new Set([
364
365
  function isGlobalHtmlAttribute(attrName) {
365
366
  return GLOBAL_ATTRIBUTE.has(attrName);
366
367
  }
367
- /**
368
- * Map composed of properties to attributes not following the HTML property to attribute mapping
369
- * convention.
370
- */
371
- const NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING = new Map([
372
- ['accessKey', 'accesskey'],
373
- ['readOnly', 'readonly'],
374
- ['tabIndex', 'tabindex'],
375
- ['bgColor', 'bgcolor'],
376
- ['colSpan', 'colspan'],
377
- ['rowSpan', 'rowspan'],
378
- ['contentEditable', 'contenteditable'],
379
- ['crossOrigin', 'crossorigin'],
380
- ['dateTime', 'datetime'],
381
- ['formAction', 'formaction'],
382
- ['isMap', 'ismap'],
383
- ['maxLength', 'maxlength'],
384
- ['minLength', 'minlength'],
385
- ['noValidate', 'novalidate'],
386
- ['useMap', 'usemap'],
387
- ['htmlFor', 'for'],
388
- ]);
368
+ // Convoluted map generation so that @lwc/shared remains fully tree-shakable (verify-treeshakable)
369
+ const { NO_STANDARD_ATTRIBUTE_PROPERTY_MAPPING, NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING } =
370
+ /*#__PURE__*/ (() => {
371
+ /**
372
+ * Map composed of properties to attributes not following the HTML property to attribute mapping
373
+ * convention.
374
+ */
375
+ const NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING = new Map([
376
+ ['accessKey', 'accesskey'],
377
+ ['readOnly', 'readonly'],
378
+ ['tabIndex', 'tabindex'],
379
+ ['bgColor', 'bgcolor'],
380
+ ['colSpan', 'colspan'],
381
+ ['rowSpan', 'rowspan'],
382
+ ['contentEditable', 'contenteditable'],
383
+ ['crossOrigin', 'crossorigin'],
384
+ ['dateTime', 'datetime'],
385
+ ['formAction', 'formaction'],
386
+ ['isMap', 'ismap'],
387
+ ['maxLength', 'maxlength'],
388
+ ['minLength', 'minlength'],
389
+ ['noValidate', 'novalidate'],
390
+ ['useMap', 'usemap'],
391
+ ['htmlFor', 'for'],
392
+ ]);
393
+ /**
394
+ * Inverted map with attribute name key and property name value.
395
+ */
396
+ const NO_STANDARD_ATTRIBUTE_PROPERTY_MAPPING = new Map();
397
+ NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING.forEach((value, key) => NO_STANDARD_ATTRIBUTE_PROPERTY_MAPPING.set(value, key));
398
+ return {
399
+ NO_STANDARD_ATTRIBUTE_PROPERTY_MAPPING,
400
+ NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING,
401
+ };
402
+ })();
389
403
  /**
390
404
  * Map associating previously transformed HTML property into HTML attribute.
391
405
  */
392
406
  const CACHED_PROPERTY_ATTRIBUTE_MAPPING = new Map();
407
+ /**
408
+ * Map associating previously transformed HTML attribute into HTML property.
409
+ */
410
+ const CACHED_ATTRIBUTE_PROPERTY_MAPPING = new Map();
393
411
  function htmlPropertyToAttribute(propName) {
394
412
  const ariaAttributeName = AriaPropNameToAttrNameMap[propName];
395
413
  if (!isUndefined(ariaAttributeName)) {
@@ -418,6 +436,23 @@ function htmlPropertyToAttribute(propName) {
418
436
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
419
437
  return attributeName;
420
438
  }
439
+ function htmlAttributeToProperty(attrName) {
440
+ const ariaPropertyName = AriaAttrNameToPropNameMap[attrName];
441
+ if (!isUndefined(ariaPropertyName)) {
442
+ return ariaPropertyName;
443
+ }
444
+ const specialPropertyName = NO_STANDARD_ATTRIBUTE_PROPERTY_MAPPING.get(attrName);
445
+ if (!isUndefined(specialPropertyName)) {
446
+ return specialPropertyName;
447
+ }
448
+ const cachedPropertyName = CACHED_ATTRIBUTE_PROPERTY_MAPPING.get(attrName);
449
+ if (!isUndefined(cachedPropertyName)) {
450
+ return cachedPropertyName;
451
+ }
452
+ const propertyName = StringReplace.call(attrName, CAMEL_REGEX, (g) => g[1].toUpperCase());
453
+ CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
454
+ return propertyName;
455
+ }
421
456
 
422
457
  /*
423
458
  * Copyright (c) 2020, salesforce.com, inc.
@@ -454,9 +489,9 @@ const hasNativeSymbolSupport = /*@__PURE__*/ (() => Symbol('x').toString() === '
454
489
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
455
490
  */
456
491
  // Increment whenever the LWC template compiler changes
457
- const LWC_VERSION = "2.30.1";
492
+ const LWC_VERSION = "2.30.3";
458
493
  const LWC_VERSION_COMMENT = `LWC compiler v${LWC_VERSION}`;
459
494
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
460
495
 
461
- export { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap, ArrayConcat, ArrayCopyWithin, ArrayFill, ArrayFilter, ArrayFind, ArrayIndexOf, ArrayJoin, ArrayMap, ArrayPop, ArrayPush, ArrayReduce, ArrayReverse, ArrayShift, ArraySlice, ArraySome, ArraySort, ArraySplice, ArrayUnshift, HTML_NAMESPACE, KEY__IS_NATIVE_SHADOW_ROOT_DEFINED, KEY__SCOPED_CSS, KEY__SHADOW_RESOLVER, KEY__SHADOW_RESOLVER_PRIVATE, KEY__SHADOW_STATIC, KEY__SHADOW_STATIC_PRIVATE, KEY__SHADOW_TOKEN, KEY__SHADOW_TOKEN_PRIVATE, KEY__SYNTHETIC_MODE, LWC_VERSION, LWC_VERSION_COMMENT, LWC_VERSION_COMMENT_REGEX, MATHML_NAMESPACE, SVG_NAMESPACE, StringCharCodeAt, StringFromCharCode, StringReplace, StringSlice, StringToLowerCase, XLINK_NAMESPACE, XML_NAMESPACE, assert, assign, create, defineProperties, defineProperty, forEach, freeze, getOwnPropertyDescriptor, getOwnPropertyNames, getPropertyDescriptor, getPrototypeOf, _globalThis as globalThis, hasNativeSymbolSupport, hasOwnProperty, htmlEscape, htmlPropertyToAttribute, isAriaAttribute, isArray, isBoolean, isBooleanAttribute, isFalse, isFrozen, isFunction, isGlobalHtmlAttribute, isNull, isNumber, isObject, isString, isTrue, isUndefined, isVoidElement, keys, noop, seal, setPrototypeOf, toString };
462
- /** version: 2.30.1 */
496
+ export { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap, ArrayConcat, ArrayCopyWithin, ArrayFill, ArrayFilter, ArrayFind, ArrayIndexOf, ArrayJoin, ArrayMap, ArrayPop, ArrayPush, ArrayReduce, ArrayReverse, ArrayShift, ArraySlice, ArraySome, ArraySort, ArraySplice, ArrayUnshift, HTML_NAMESPACE, KEY__IS_NATIVE_SHADOW_ROOT_DEFINED, KEY__SCOPED_CSS, KEY__SHADOW_RESOLVER, KEY__SHADOW_RESOLVER_PRIVATE, KEY__SHADOW_STATIC, KEY__SHADOW_STATIC_PRIVATE, KEY__SHADOW_TOKEN, KEY__SHADOW_TOKEN_PRIVATE, KEY__SYNTHETIC_MODE, LWC_VERSION, LWC_VERSION_COMMENT, LWC_VERSION_COMMENT_REGEX, MATHML_NAMESPACE, SVG_NAMESPACE, StringCharCodeAt, StringFromCharCode, StringReplace, StringSlice, StringToLowerCase, XLINK_NAMESPACE, XML_NAMESPACE, assert, assign, create, defineProperties, defineProperty, forEach, freeze, getOwnPropertyDescriptor, getOwnPropertyNames, getPropertyDescriptor, getPrototypeOf, _globalThis as globalThis, hasNativeSymbolSupport, hasOwnProperty, htmlAttributeToProperty, htmlEscape, htmlPropertyToAttribute, isAriaAttribute, isArray, isBoolean, isBooleanAttribute, isFalse, isFrozen, isFunction, isGlobalHtmlAttribute, isNull, isNumber, isObject, isString, isTrue, isUndefined, isVoidElement, keys, noop, seal, setPrototypeOf, toString };
497
+ /** version: 2.30.3 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/shared",
3
- "version": "2.30.1",
3
+ "version": "2.30.3",
4
4
  "description": "Utilities and methods that are shared across packages",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -1,3 +1,4 @@
1
1
  export declare function isBooleanAttribute(attrName: string, tagName: string): boolean;
2
2
  export declare function isGlobalHtmlAttribute(attrName: string): boolean;
3
3
  export declare function htmlPropertyToAttribute(propName: string): string;
4
+ export declare function htmlAttributeToProperty(attrName: string): string;