mirror of https://github.com/sveltejs/svelte
Merge 82fc329384 into 5895c637b0
commit
bb3d3573d7
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: keep an own `__proto__` key in `$state.snapshot`
|
||||
@ -0,0 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<div>["__proto__","b"]</div><div>true</div><div></div>`
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
// An own `__proto__` key comes from JSON, which is where state hydrated
|
||||
// from a response, from storage, or from a query string comes from.
|
||||
let state = $state(JSON.parse('{"__proto__":{"admin":true},"b":2}'));
|
||||
|
||||
const snapshot = $state.snapshot(state);
|
||||
</script>
|
||||
|
||||
<div>{JSON.stringify(Object.keys(snapshot))}</div>
|
||||
<div>{Object.getPrototypeOf(snapshot) === Object.prototype}</div>
|
||||
<div>{snapshot.admin}</div>
|
||||
Loading…
Reference in new issue