Skip to content
Myr

Correctly handle objects without prototype

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent b9169b1 · Browse files · 2 files+23 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+23 added−2 removed

  • tests:+18 added−0 removed
  • other:+5 added−2 removed

2 files+23 added−2 removed

modified:__tests__/base.js+18 added
133 unmodified lines
134 expect(result[0].a).toEqual(2)135 expect(result[1].a).toEqual(2)136 })137138 it("works with objects without proto", () => {139 const base = Object.create(null)140 base.x = 1141 base.y = Object.create(null)142 base.y.y = 2143 expect(base.__proto__).toBe(undefined)144 const next = produce(base, draft => {145 draft.y.z = 3146 draft.y.y++147 draft.x++148 })149 expect(next).toEqual({150 x: 2,151 y: {y: 3, z: 3}152 })153 expect(next.__proto__).toBe(undefined)154 })155156 it("should support reading arrays", () => {157 const nextState = produce(baseState, s => {158 s.anArray.slice()159 })
646 unmodified lines
modified:src/common.js+5 added-2 removed