mirror of
https://github.com/robertkrimen/otto
synced 2025-10-12 20:27:30 +08:00
Use defineOwnProperty (not put) for Array (literal) initialization
This commit is contained in:
parent
a8c31cf457
commit
599d565e55
|
@ -40,6 +40,16 @@ func TestArray(t *testing.T) {
|
|||
abc.length = 2;
|
||||
abc;
|
||||
`, "0,1")
|
||||
|
||||
test(`
|
||||
Object.defineProperty(Array.prototype, "0", {
|
||||
value: 100,
|
||||
writable: false,
|
||||
configurable: true
|
||||
});
|
||||
abc = [101];
|
||||
abc.hasOwnProperty("0") && abc[0] === 101;
|
||||
`, "true")
|
||||
}
|
||||
|
||||
func TestArray_toString(t *testing.T) {
|
||||
|
|
|
@ -781,7 +781,7 @@ func (runtime *_runtime) newArray(length uint32) *_object {
|
|||
func (runtime *_runtime) newArrayOf(valueArray []Value) *_object {
|
||||
self := runtime.newArray(uint32(len(valueArray)))
|
||||
for index, value := range valueArray {
|
||||
self.put(strconv.FormatInt(int64(index), 10), value, false)
|
||||
self.defineProperty(strconv.FormatInt(int64(index), 10), value, 0111, false)
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
|
|
@ -217,6 +217,7 @@ func objectPut(self *_object, name string, value Value, throw bool) {
|
|||
typeErrorResult(throw)
|
||||
return
|
||||
}
|
||||
// TODO This is not exacting to the specification
|
||||
// TODO Shortcut?
|
||||
property := self.getOwnProperty(name)
|
||||
if property == nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user