diff --git a/lib/lists.js b/lib/lists.js index 5ee8a6f7..b11d4b1f 100644 --- a/lib/lists.js +++ b/lib/lists.js @@ -18,5 +18,10 @@ util.createMethods(List.prototype, constants.propTypes.LIST, [ ], true); function create(realmId, info) { - return util.createList(List.prototype, realmId, info, true); + let meta = util.createList(List.prototype, realmId, info, true); + let list = Object.create(meta); + + Object.preventExtensions(list); + + return list; } diff --git a/lib/util.js b/lib/util.js index 699662dc..9bd68db9 100644 --- a/lib/util.js +++ b/lib/util.js @@ -21,7 +21,7 @@ function createList(prototype, realmId, info, mutable) { list[keys.resize] = function(length) { if (length == null) { - length = this.length; + length = list.length; } if (length == size) { return; @@ -39,11 +39,11 @@ function createList(prototype, realmId, info, mutable) { }; } - Object.defineProperties(this, props); + Object.defineProperties(list, props); } else if (length < size) { for (let i = size - 1; i >= length; i--) { - delete this[i]; + delete list[i]; } }