diff --git a/object_goreflect.go b/object_goreflect.go index f8ca6d05..f5b5e8f2 100644 --- a/object_goreflect.go +++ b/object_goreflect.go @@ -221,6 +221,9 @@ func (o *objectGoReflect) _getMethod(jsName string) reflect.Value { func (o *objectGoReflect) elemToValue(ev reflect.Value) (Value, reflectValueWrapper) { if isContainer(ev.Kind()) { + if ev.CanAddr() { + ev = ev.Addr() + } ret := o.val.runtime.toValue(ev.Interface(), ev) if obj, ok := ret.(*Object); ok { if w, ok := obj.self.(reflectValueWrapper); ok { diff --git a/object_goreflect_test.go b/object_goreflect_test.go index 6dc096c8..8b71b332 100644 --- a/object_goreflect_test.go +++ b/object_goreflect_test.go @@ -1665,3 +1665,23 @@ func TestGoReflectUnexportedEmbedStruct(t *testing.T) { }) } } + +func TestNestedSliceAddr(t *testing.T) { + type document struct { + Items []any + } + + var d document + runtime := New() + runtime.Set("d", &d) + + _, err := runtime.RunString(` + d.Items.push("Hello"); + `) + if err != nil { + t.Fatal(err) + } + if len(d.Items) != 1 || d.Items[0] != "Hello" { + t.Fatal(d.Items) + } +}