@vue/shared 3.5.41 → 3.5.43

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/shared v3.5.41
2
+ * @vue/shared v3.5.43
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -271,10 +271,10 @@ function normalizeStyle(value) {
271
271
  }
272
272
  const listDelimiterRE = /;(?![^(]*\))/g;
273
273
  const propertyDelimiterRE = /:([^]+)/;
274
- const styleCommentRE = /\/\*[^]*?\*\//g;
274
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
275
275
  function parseStringStyle(cssText) {
276
276
  const ret = {};
277
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
277
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
278
278
  if (item) {
279
279
  const tmp = item.split(propertyDelimiterRE);
280
280
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -344,7 +344,7 @@ const isBooleanAttr = /* @__PURE__ */ makeMap(
344
344
  function includeBooleanAttr(value) {
345
345
  return !!value || value === "";
346
346
  }
347
- const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
347
+ const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u000d\u0020]/;
348
348
  const attrValidationCache = {};
349
349
  function isSSRSafeAttrName(name) {
350
350
  if (attrValidationCache.hasOwnProperty(name)) {
@@ -435,15 +435,72 @@ function getEscapedCssVarName(key, doubleEscape) {
435
435
  );
436
436
  }
437
437
 
438
- function looseCompareArrays(a, b) {
438
+ function looseCompareArrays(a, b, seen) {
439
439
  if (a.length !== b.length) return false;
440
440
  let equal = true;
441
441
  for (let i = 0; equal && i < a.length; i++) {
442
- equal = looseEqual(a[i], b[i]);
442
+ equal = looseEqual(a[i], b[i], seen);
443
443
  }
444
444
  return equal;
445
445
  }
446
- function looseEqual(a, b) {
446
+ function looseCompareCollections(a, b, seen) {
447
+ if (a.size !== b.size) return false;
448
+ const candidates = Array.from(b);
449
+ const matched = new Uint8Array(candidates.length);
450
+ for (const item of a) {
451
+ let index = -1;
452
+ for (let i = 0; i < candidates.length; i++) {
453
+ if (!matched[i] && looseEqual(item, candidates[i], seen)) {
454
+ index = i;
455
+ break;
456
+ }
457
+ }
458
+ if (index < 0) return false;
459
+ matched[index] = 1;
460
+ }
461
+ return true;
462
+ }
463
+ function looseCompareObjects(a, b, seen) {
464
+ let aValidType = isMap(a);
465
+ let bValidType = isMap(b);
466
+ if (aValidType || bValidType) {
467
+ return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
468
+ }
469
+ aValidType = isSet(a);
470
+ bValidType = isSet(b);
471
+ if (aValidType || bValidType) {
472
+ return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
473
+ }
474
+ const aKeysCount = Object.keys(a).length;
475
+ const bKeysCount = Object.keys(b).length;
476
+ if (aKeysCount !== bKeysCount) {
477
+ return false;
478
+ }
479
+ for (const key in a) {
480
+ const aHasKey = a.hasOwnProperty(key);
481
+ const bHasKey = b.hasOwnProperty(key);
482
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) {
483
+ return false;
484
+ }
485
+ }
486
+ return String(a) === String(b);
487
+ }
488
+ function looseCompareNested(a, b, seen, compare) {
489
+ if (!seen) {
490
+ seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
491
+ }
492
+ const [seenA, seenB] = seen;
493
+ if (seenA.has(a) || seenB.has(b)) {
494
+ return seenA.get(a) === b && seenB.get(b) === a;
495
+ }
496
+ seenA.set(a, b);
497
+ seenB.set(b, a);
498
+ const equal = compare(a, b, seen);
499
+ seenA.delete(a);
500
+ seenB.delete(b);
501
+ return equal;
502
+ }
503
+ function looseEqual(a, b, seen) {
447
504
  if (a === b) return true;
448
505
  let aValidType = isDate(a);
449
506
  let bValidType = isDate(b);
@@ -458,7 +515,7 @@ function looseEqual(a, b) {
458
515
  aValidType = isArray(a);
459
516
  bValidType = isArray(b);
460
517
  if (aValidType || bValidType) {
461
- return aValidType && bValidType ? looseCompareArrays(a, b) : false;
518
+ return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
462
519
  }
463
520
  aValidType = isObject(a);
464
521
  bValidType = isObject(b);
@@ -466,18 +523,7 @@ function looseEqual(a, b) {
466
523
  if (!aValidType || !bValidType) {
467
524
  return false;
468
525
  }
469
- const aKeysCount = Object.keys(a).length;
470
- const bKeysCount = Object.keys(b).length;
471
- if (aKeysCount !== bKeysCount) {
472
- return false;
473
- }
474
- for (const key in a) {
475
- const aHasKey = a.hasOwnProperty(key);
476
- const bHasKey = b.hasOwnProperty(key);
477
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
478
- return false;
479
- }
480
- }
526
+ return looseCompareNested(a, b, seen, looseCompareObjects);
481
527
  }
482
528
  return String(a) === String(b);
483
529
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/shared v3.5.41
2
+ * @vue/shared v3.5.43
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -271,10 +271,10 @@ function normalizeStyle(value) {
271
271
  }
272
272
  const listDelimiterRE = /;(?![^(]*\))/g;
273
273
  const propertyDelimiterRE = /:([^]+)/;
274
- const styleCommentRE = /\/\*[^]*?\*\//g;
274
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
275
275
  function parseStringStyle(cssText) {
276
276
  const ret = {};
277
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
277
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
278
278
  if (item) {
279
279
  const tmp = item.split(propertyDelimiterRE);
280
280
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -344,7 +344,7 @@ const isBooleanAttr = /* @__PURE__ */ makeMap(
344
344
  function includeBooleanAttr(value) {
345
345
  return !!value || value === "";
346
346
  }
347
- const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
347
+ const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u000d\u0020]/;
348
348
  const attrValidationCache = {};
349
349
  function isSSRSafeAttrName(name) {
350
350
  if (attrValidationCache.hasOwnProperty(name)) {
@@ -435,15 +435,72 @@ function getEscapedCssVarName(key, doubleEscape) {
435
435
  );
436
436
  }
437
437
 
438
- function looseCompareArrays(a, b) {
438
+ function looseCompareArrays(a, b, seen) {
439
439
  if (a.length !== b.length) return false;
440
440
  let equal = true;
441
441
  for (let i = 0; equal && i < a.length; i++) {
442
- equal = looseEqual(a[i], b[i]);
442
+ equal = looseEqual(a[i], b[i], seen);
443
443
  }
444
444
  return equal;
445
445
  }
446
- function looseEqual(a, b) {
446
+ function looseCompareCollections(a, b, seen) {
447
+ if (a.size !== b.size) return false;
448
+ const candidates = Array.from(b);
449
+ const matched = new Uint8Array(candidates.length);
450
+ for (const item of a) {
451
+ let index = -1;
452
+ for (let i = 0; i < candidates.length; i++) {
453
+ if (!matched[i] && looseEqual(item, candidates[i], seen)) {
454
+ index = i;
455
+ break;
456
+ }
457
+ }
458
+ if (index < 0) return false;
459
+ matched[index] = 1;
460
+ }
461
+ return true;
462
+ }
463
+ function looseCompareObjects(a, b, seen) {
464
+ let aValidType = isMap(a);
465
+ let bValidType = isMap(b);
466
+ if (aValidType || bValidType) {
467
+ return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
468
+ }
469
+ aValidType = isSet(a);
470
+ bValidType = isSet(b);
471
+ if (aValidType || bValidType) {
472
+ return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
473
+ }
474
+ const aKeysCount = Object.keys(a).length;
475
+ const bKeysCount = Object.keys(b).length;
476
+ if (aKeysCount !== bKeysCount) {
477
+ return false;
478
+ }
479
+ for (const key in a) {
480
+ const aHasKey = a.hasOwnProperty(key);
481
+ const bHasKey = b.hasOwnProperty(key);
482
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) {
483
+ return false;
484
+ }
485
+ }
486
+ return String(a) === String(b);
487
+ }
488
+ function looseCompareNested(a, b, seen, compare) {
489
+ if (!seen) {
490
+ seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
491
+ }
492
+ const [seenA, seenB] = seen;
493
+ if (seenA.has(a) || seenB.has(b)) {
494
+ return seenA.get(a) === b && seenB.get(b) === a;
495
+ }
496
+ seenA.set(a, b);
497
+ seenB.set(b, a);
498
+ const equal = compare(a, b, seen);
499
+ seenA.delete(a);
500
+ seenB.delete(b);
501
+ return equal;
502
+ }
503
+ function looseEqual(a, b, seen) {
447
504
  if (a === b) return true;
448
505
  let aValidType = isDate(a);
449
506
  let bValidType = isDate(b);
@@ -458,7 +515,7 @@ function looseEqual(a, b) {
458
515
  aValidType = isArray(a);
459
516
  bValidType = isArray(b);
460
517
  if (aValidType || bValidType) {
461
- return aValidType && bValidType ? looseCompareArrays(a, b) : false;
518
+ return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
462
519
  }
463
520
  aValidType = isObject(a);
464
521
  bValidType = isObject(b);
@@ -466,18 +523,7 @@ function looseEqual(a, b) {
466
523
  if (!aValidType || !bValidType) {
467
524
  return false;
468
525
  }
469
- const aKeysCount = Object.keys(a).length;
470
- const bKeysCount = Object.keys(b).length;
471
- if (aKeysCount !== bKeysCount) {
472
- return false;
473
- }
474
- for (const key in a) {
475
- const aHasKey = a.hasOwnProperty(key);
476
- const bHasKey = b.hasOwnProperty(key);
477
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
478
- return false;
479
- }
480
- }
526
+ return looseCompareNested(a, b, seen, looseCompareObjects);
481
527
  }
482
528
  return String(a) === String(b);
483
529
  }
package/dist/shared.d.ts CHANGED
@@ -298,7 +298,8 @@ export declare function escapeHtmlComment(src: string): string;
298
298
  export declare const cssVarNameEscapeSymbolsRE: RegExp;
299
299
  export declare function getEscapedCssVarName(key: string, doubleEscape: boolean): string;
300
300
 
301
- export declare function looseEqual(a: any, b: any): boolean;
301
+ type ComparisonState = [Map<any, any>, Map<any, any>];
302
+ export declare function looseEqual(a: any, b: any, seen?: ComparisonState): boolean;
302
303
  export declare function looseIndexOf(arr: any[], val: any): number;
303
304
 
304
305
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/shared v3.5.41
2
+ * @vue/shared v3.5.43
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -267,10 +267,10 @@ function normalizeStyle(value) {
267
267
  }
268
268
  const listDelimiterRE = /;(?![^(]*\))/g;
269
269
  const propertyDelimiterRE = /:([^]+)/;
270
- const styleCommentRE = /\/\*[^]*?\*\//g;
270
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
271
271
  function parseStringStyle(cssText) {
272
272
  const ret = {};
273
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
273
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
274
274
  if (item) {
275
275
  const tmp = item.split(propertyDelimiterRE);
276
276
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -340,7 +340,7 @@ const isBooleanAttr = /* @__PURE__ */ makeMap(
340
340
  function includeBooleanAttr(value) {
341
341
  return !!value || value === "";
342
342
  }
343
- const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
343
+ const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u000d\u0020]/;
344
344
  const attrValidationCache = {};
345
345
  function isSSRSafeAttrName(name) {
346
346
  if (attrValidationCache.hasOwnProperty(name)) {
@@ -431,15 +431,72 @@ function getEscapedCssVarName(key, doubleEscape) {
431
431
  );
432
432
  }
433
433
 
434
- function looseCompareArrays(a, b) {
434
+ function looseCompareArrays(a, b, seen) {
435
435
  if (a.length !== b.length) return false;
436
436
  let equal = true;
437
437
  for (let i = 0; equal && i < a.length; i++) {
438
- equal = looseEqual(a[i], b[i]);
438
+ equal = looseEqual(a[i], b[i], seen);
439
439
  }
440
440
  return equal;
441
441
  }
442
- function looseEqual(a, b) {
442
+ function looseCompareCollections(a, b, seen) {
443
+ if (a.size !== b.size) return false;
444
+ const candidates = Array.from(b);
445
+ const matched = new Uint8Array(candidates.length);
446
+ for (const item of a) {
447
+ let index = -1;
448
+ for (let i = 0; i < candidates.length; i++) {
449
+ if (!matched[i] && looseEqual(item, candidates[i], seen)) {
450
+ index = i;
451
+ break;
452
+ }
453
+ }
454
+ if (index < 0) return false;
455
+ matched[index] = 1;
456
+ }
457
+ return true;
458
+ }
459
+ function looseCompareObjects(a, b, seen) {
460
+ let aValidType = isMap(a);
461
+ let bValidType = isMap(b);
462
+ if (aValidType || bValidType) {
463
+ return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
464
+ }
465
+ aValidType = isSet(a);
466
+ bValidType = isSet(b);
467
+ if (aValidType || bValidType) {
468
+ return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
469
+ }
470
+ const aKeysCount = Object.keys(a).length;
471
+ const bKeysCount = Object.keys(b).length;
472
+ if (aKeysCount !== bKeysCount) {
473
+ return false;
474
+ }
475
+ for (const key in a) {
476
+ const aHasKey = a.hasOwnProperty(key);
477
+ const bHasKey = b.hasOwnProperty(key);
478
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) {
479
+ return false;
480
+ }
481
+ }
482
+ return String(a) === String(b);
483
+ }
484
+ function looseCompareNested(a, b, seen, compare) {
485
+ if (!seen) {
486
+ seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
487
+ }
488
+ const [seenA, seenB] = seen;
489
+ if (seenA.has(a) || seenB.has(b)) {
490
+ return seenA.get(a) === b && seenB.get(b) === a;
491
+ }
492
+ seenA.set(a, b);
493
+ seenB.set(b, a);
494
+ const equal = compare(a, b, seen);
495
+ seenA.delete(a);
496
+ seenB.delete(b);
497
+ return equal;
498
+ }
499
+ function looseEqual(a, b, seen) {
443
500
  if (a === b) return true;
444
501
  let aValidType = isDate(a);
445
502
  let bValidType = isDate(b);
@@ -454,7 +511,7 @@ function looseEqual(a, b) {
454
511
  aValidType = isArray(a);
455
512
  bValidType = isArray(b);
456
513
  if (aValidType || bValidType) {
457
- return aValidType && bValidType ? looseCompareArrays(a, b) : false;
514
+ return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
458
515
  }
459
516
  aValidType = isObject(a);
460
517
  bValidType = isObject(b);
@@ -462,18 +519,7 @@ function looseEqual(a, b) {
462
519
  if (!aValidType || !bValidType) {
463
520
  return false;
464
521
  }
465
- const aKeysCount = Object.keys(a).length;
466
- const bKeysCount = Object.keys(b).length;
467
- if (aKeysCount !== bKeysCount) {
468
- return false;
469
- }
470
- for (const key in a) {
471
- const aHasKey = a.hasOwnProperty(key);
472
- const bHasKey = b.hasOwnProperty(key);
473
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
474
- return false;
475
- }
476
- }
522
+ return looseCompareNested(a, b, seen, looseCompareObjects);
477
523
  }
478
524
  return String(a) === String(b);
479
525
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/shared",
3
- "version": "3.5.41",
3
+ "version": "3.5.43",
4
4
  "description": "internal utils shared across @vue packages",
5
5
  "main": "index.js",
6
6
  "module": "dist/shared.esm-bundler.js",