Skip to content

Commit

Permalink
explain the explicit call to trapForSet
Browse files Browse the repository at this point in the history
  • Loading branch information
warpech committed Aug 15, 2019
1 parent 21af2ec commit e81f6a4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/jsonpatcherproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ const JSONPatcherProxy = (function() {
if (isTreeAnArray && !isNonSerializableArrayProperty) {
const index = parseInt(key, 10);
if (index > tree.length) {
// force call trapForSet for implicit undefined elements of the array added by the JS engine
// because JSON-Patch spec prohibits adding an index that is higher than array.length
trapForSet(instance, tree, (index - 1) + '', undefined);
}
}
Expand Down

0 comments on commit e81f6a4

Please sign in to comment.