@vue/shared 3.2.2 → 3.2.6

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.
@@ -116,6 +116,13 @@ const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
116
116
  `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
117
117
  `loop,open,required,reversed,scoped,seamless,` +
118
118
  `checked,muted,multiple,selected`);
119
+ /**
120
+ * Boolean attributes should be included if the value is truthy or ''.
121
+ * e.g. <select multiple> compiles to { multiple: '' }
122
+ */
123
+ function includeBooleanAttr(value) {
124
+ return !!value || value === '';
125
+ }
119
126
  const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
120
127
  const attrValidationCache = {};
121
128
  function isSSRSafeAttrName(name) {
@@ -425,7 +432,9 @@ function looseIndexOf(arr, val) {
425
432
  const toDisplayString = (val) => {
426
433
  return val == null
427
434
  ? ''
428
- : isArray(val) || (isObject(val) && val.toString === objectToString)
435
+ : isArray(val) ||
436
+ (isObject(val) &&
437
+ (val.toString === objectToString || !isFunction(val.toString)))
429
438
  ? JSON.stringify(val, replacer, 2)
430
439
  : String(val);
431
440
  };
@@ -589,6 +598,7 @@ exports.getGlobalThis = getGlobalThis;
589
598
  exports.hasChanged = hasChanged;
590
599
  exports.hasOwn = hasOwn;
591
600
  exports.hyphenate = hyphenate;
601
+ exports.includeBooleanAttr = includeBooleanAttr;
592
602
  exports.invokeArrayFns = invokeArrayFns;
593
603
  exports.isArray = isArray;
594
604
  exports.isBooleanAttr = isBooleanAttr;
@@ -116,6 +116,13 @@ const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
116
116
  `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
117
117
  `loop,open,required,reversed,scoped,seamless,` +
118
118
  `checked,muted,multiple,selected`);
119
+ /**
120
+ * Boolean attributes should be included if the value is truthy or ''.
121
+ * e.g. <select multiple> compiles to { multiple: '' }
122
+ */
123
+ function includeBooleanAttr(value) {
124
+ return !!value || value === '';
125
+ }
119
126
  const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
120
127
  const attrValidationCache = {};
121
128
  function isSSRSafeAttrName(name) {
@@ -425,7 +432,9 @@ function looseIndexOf(arr, val) {
425
432
  const toDisplayString = (val) => {
426
433
  return val == null
427
434
  ? ''
428
- : isArray(val) || (isObject(val) && val.toString === objectToString)
435
+ : isArray(val) ||
436
+ (isObject(val) &&
437
+ (val.toString === objectToString || !isFunction(val.toString)))
429
438
  ? JSON.stringify(val, replacer, 2)
430
439
  : String(val);
431
440
  };
@@ -588,6 +597,7 @@ exports.getGlobalThis = getGlobalThis;
588
597
  exports.hasChanged = hasChanged;
589
598
  exports.hasOwn = hasOwn;
590
599
  exports.hyphenate = hyphenate;
600
+ exports.includeBooleanAttr = includeBooleanAttr;
591
601
  exports.invokeArrayFns = invokeArrayFns;
592
602
  exports.isArray = isArray;
593
603
  exports.isBooleanAttr = isBooleanAttr;
package/dist/shared.d.ts CHANGED
@@ -48,6 +48,12 @@ export declare const hasOwn: (val: object, key: string | symbol) => key is never
48
48
  */
49
49
  export declare const hyphenate: (str: string) => string;
50
50
 
51
+ /**
52
+ * Boolean attributes should be included if the value is truthy or ''.
53
+ * e.g. <select multiple> compiles to { multiple: '' }
54
+ */
55
+ export declare function includeBooleanAttr(value: unknown): boolean;
56
+
51
57
  export declare const invokeArrayFns: (fns: Function[], arg?: any) => void;
52
58
 
53
59
  export declare const isArray: (arg: any) => arg is any[];
@@ -112,6 +112,13 @@ const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +
112
112
  `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
113
113
  `loop,open,required,reversed,scoped,seamless,` +
114
114
  `checked,muted,multiple,selected`);
115
+ /**
116
+ * Boolean attributes should be included if the value is truthy or ''.
117
+ * e.g. <select multiple> compiles to { multiple: '' }
118
+ */
119
+ function includeBooleanAttr(value) {
120
+ return !!value || value === '';
121
+ }
115
122
  const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
116
123
  const attrValidationCache = {};
117
124
  function isSSRSafeAttrName(name) {
@@ -421,7 +428,9 @@ function looseIndexOf(arr, val) {
421
428
  const toDisplayString = (val) => {
422
429
  return val == null
423
430
  ? ''
424
- : isArray(val) || (isObject(val) && val.toString === objectToString)
431
+ : isArray(val) ||
432
+ (isObject(val) &&
433
+ (val.toString === objectToString || !isFunction(val.toString)))
425
434
  ? JSON.stringify(val, replacer, 2)
426
435
  : String(val);
427
436
  };
@@ -569,4 +578,4 @@ const getGlobalThis = () => {
569
578
  : {}));
570
579
  };
571
580
 
572
- export { EMPTY_ARR, EMPTY_OBJ, NO, NOOP, PatchFlagNames, babelParserDefaultPlugins, camelize, capitalize, def, escapeHtml, escapeHtmlComment, extend, generateCodeFrame, getGlobalThis, hasChanged, hasOwn, hyphenate, invokeArrayFns, isArray, isBooleanAttr, isDate, isFunction, isGloballyWhitelisted, isHTMLTag, isIntegerKey, isKnownHtmlAttr, isKnownSvgAttr, isMap, isModelListener, isNoUnitNumericStyleProp, isObject, isOn, isPlainObject, isPromise, isReservedProp, isSSRSafeAttrName, isSVGTag, isSet, isSpecialBooleanAttr, isString, isSymbol, isVoidTag, looseEqual, looseIndexOf, makeMap, normalizeClass, normalizeProps, normalizeStyle, objectToString, parseStringStyle, propsToAttrMap, remove, slotFlagsText, stringifyStyle, toDisplayString, toHandlerKey, toNumber, toRawType, toTypeString };
581
+ export { EMPTY_ARR, EMPTY_OBJ, NO, NOOP, PatchFlagNames, babelParserDefaultPlugins, camelize, capitalize, def, escapeHtml, escapeHtmlComment, extend, generateCodeFrame, getGlobalThis, hasChanged, hasOwn, hyphenate, includeBooleanAttr, invokeArrayFns, isArray, isBooleanAttr, isDate, isFunction, isGloballyWhitelisted, isHTMLTag, isIntegerKey, isKnownHtmlAttr, isKnownSvgAttr, isMap, isModelListener, isNoUnitNumericStyleProp, isObject, isOn, isPlainObject, isPromise, isReservedProp, isSSRSafeAttrName, isSVGTag, isSet, isSpecialBooleanAttr, isString, isSymbol, isVoidTag, looseEqual, looseIndexOf, makeMap, normalizeClass, normalizeProps, normalizeStyle, objectToString, parseStringStyle, propsToAttrMap, remove, slotFlagsText, stringifyStyle, toDisplayString, toHandlerKey, toNumber, toRawType, toTypeString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/shared",
3
- "version": "3.2.2",
3
+ "version": "3.2.6",
4
4
  "description": "internal utils shared across @vue packages",
5
5
  "main": "index.js",
6
6
  "module": "dist/shared.esm-bundler.js",