Align the error thrown for assigning to read-only collection properties

This commit is contained in:
Thomas Goyne 2017-09-26 13:10:39 -07:00
parent 741d19458b
commit cf0f0d127f

View File

@ -83,7 +83,10 @@ const traps = {
return true;
}
return Reflect.set(collection, property, value, collection);
if (!Reflect.set(collection, property, value, collection)) {
throw new TypeError(`Cannot assign to read only property '${property}'`)
}
return true;
},
ownKeys(collection) {
return Reflect.ownKeys(collection).concat(Array.from({ length: collection.length }, (value, key) => String(key)));