1
0
mirror of synced 2024-11-21 21:06:04 +03:00

fix: Blob objects are no longer cloned

This commit is contained in:
Zaytsev Kirill 2021-10-21 12:45:43 +03:00
parent bff166a396
commit 67dba981a1
2 changed files with 9 additions and 1 deletions

View File

@ -9,7 +9,8 @@ const cloneInstance = <T>(original: T): T => {
* case of needing to unbind reactive watchers.
*/
export default function clone<T = unknown> (value: T): T {
if (isScalar(value)) {
// scalars & immutables
if (isScalar(value) || value instanceof Blob) {
return value
}

View File

@ -76,4 +76,11 @@ describe('clone', () => {
expect(copy.sample.doSomething).toBeTruthy()
expect(copy.sample.doSomething).not.toThrow()
})
test('does not create a copy of a blob', () => {
const blob = new Blob(['{"fieldA": "fieldA"}'], { type : 'application/json' })
const copy = clone(blob)
expect(blob === copy).toBeTruthy()
})
})