Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ export class Pointer {
if (key == '__proto__' || key == 'constructor' || key == 'prototype') {
continue
}
// not sure if this the best way to handle non-existant paths...
value = (parent || {})[key]
value = undefined
if (parent && Object.prototype.hasOwnProperty.call(parent, key)) {
value = parent[key]
}
}
return {parent, key, value}
}
Expand Down
9 changes: 9 additions & 0 deletions test/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,12 @@ test('minimal array diff', t => {
]
checkRoundtrip(t, input, output, expected_patch)
})

test('issues/2ndopp', t => {
t.true(({} as any).polluted === undefined, 'toString function should not be polluted')
const value = {}
applyPatch(value, [
{op: 'add', path: '/toString/polluted', value: 'Hello!'}
])
t.true(({} as any).toString.polluted === undefined, 'toString function should still not be polluted')
})