Upstream lukeed/klona state of the touched files before ba2e73a80c

This commit is contained in:
upstream committed 2026-09-04 05:12:29 +02:00
1 parent e65d94875e
commit 1bd5b48e33
10 files changed
+4 -51

No files matched your search

-1
View File
@@ -13,7 +13,6 @@ suites.RegExps(klona);
suites.Objects(klona);
suites.Arrays(klona);
suites.ToStringTag(klona);
suites.Functions(klona);
suites.Pollutions(klona);
-1
View File
@@ -13,7 +13,6 @@ suites.RegExps(klona);
suites.Objects(klona);
suites.Arrays(klona);
suites.ToStringTag(klona);
suites.Functions(klona);
suites.Pollutions(klona);
-1
View File
@@ -10,6 +10,5 @@ suites.Nully(klona);
suites.Objects(klona);
suites.Arrays(klona);
suites.ToStringTag(klona);
suites.Pollutions(klona);
-1
View File
@@ -13,7 +13,6 @@ suites.RegExps(klona);
suites.Objects(klona);
suites.Arrays(klona);
suites.ToStringTag(klona);
suites.Functions(klona);
suites.Pollutions(klona);
-1
View File
@@ -11,7 +11,6 @@ export { default as Sets } from './set';
export { default as TypedArrays } from './typedarray';
export { default as Descriptors } from './descriptor';
export { default as Symbols } from './symbol';
export { default as ToStringTag } from './tostringtag';
export { default as Dates } from './date';
export { default as RegExps } from './regexp';
-42
View File
@@ -1,42 +0,0 @@
import { suite } from 'uvu';
import * as assert from 'assert';
export default function (klona) {
const Spoofed = suite('Symbol.toStringTag spoofing');
// A `Symbol.toStringTag` klona special-cases (eg "Map") used to misroute a
// plain object into that branch and crash.
// @see https://github.com/lukeed/klona/issues/54
Spoofed('recognized tag :: plain object is cloned, not misrouted', () => {
const input = { a: 1, b: { c: 2 }, [Symbol.toStringTag]: 'Map' };
const output = klona(input);
assert.notEqual(output, input, 'must return a new object, not the input');
assert.equal(output.a, 1);
assert.deepEqual(output.b, { c: 2 });
output.a = 999;
output.b.c = 888;
assert.equal(input.a, 1, 'mutating output.a must not affect input');
assert.equal(input.b.c, 2, 'mutating output.b must not affect input');
});
// An unrecognized `Symbol.toStringTag` used to fall through every branch
// and be returned by reference instead of cloned.
// @see https://github.com/lukeed/klona/issues/54
Spoofed('unrecognized tag :: plain object is cloned, not returned by reference', () => {
const input = { a: 1, b: { c: 2 }, [Symbol.toStringTag]: 'Foobar' };
const output = klona(input);
assert.notEqual(output, input, 'must return a new object, not the input');
assert.equal(output.a, 1);
assert.deepEqual(output.b, { c: 2 });
output.a = 999;
output.b.c = 888;
assert.equal(input.a, 1, 'mutating output.a must not affect input');
assert.equal(input.b.c, 2, 'mutating output.b must not affect input');
});
Spoofed.run();
}