Merge pull request #37 from cmath10/fix-blob-cloning
fix: Blob objects are no longer cloned
This commit is contained in:
commit
29975e3ddb
@ -9,7 +9,8 @@ const cloneInstance = <T>(original: T): T => {
|
|||||||
* case of needing to unbind reactive watchers.
|
* case of needing to unbind reactive watchers.
|
||||||
*/
|
*/
|
||||||
export default function clone<T = unknown> (value: T): T {
|
export default function clone<T = unknown> (value: T): T {
|
||||||
if (isScalar(value)) {
|
// scalars & immutables
|
||||||
|
if (isScalar(value) || value instanceof Blob) {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,4 +76,11 @@ describe('clone', () => {
|
|||||||
expect(copy.sample.doSomething).toBeTruthy()
|
expect(copy.sample.doSomething).toBeTruthy()
|
||||||
expect(copy.sample.doSomething).not.toThrow()
|
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()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user