removed the temp len binding as the issue was fixed in goja#521

This commit is contained in:
Gani Georgiev
2023-06-21 13:40:59 +03:00
parent 93606c6647
commit fc311a8d28
4 changed files with 585 additions and 203 deletions
-18
View File
@@ -79,24 +79,6 @@ func baseBinds(vm *goja.Runtime) {
return dest, nil
})
// temporary helper to properly return the length of an array
// see https://github.com/dop251/goja/issues/521
vm.Set("len", func(val any) int {
rv := reflect.ValueOf(val)
rk := rv.Kind()
if rk == reflect.Ptr {
rv = rv.Elem()
rk = rv.Kind()
}
if rk == reflect.Slice || rk == reflect.Array {
return rv.Len()
}
return 0
})
vm.Set("DynamicModel", func(call goja.ConstructorCall) *goja.Object {
shape, ok := call.Argument(0).Export().(map[string]any)
if !ok || len(shape) == 0 {
+2 -2
View File
@@ -24,7 +24,7 @@ func TestBaseBindsCount(t *testing.T) {
vm := goja.New()
baseBinds(vm)
testBindsCount(vm, "this", 15, t)
testBindsCount(vm, "this", 14, t)
}
func TestBaseBindsUnmarshal(t *testing.T) {
@@ -706,7 +706,7 @@ func TestLoadingDynamicList(t *testing.T) {
.orderBy("text ASC")
.all(result)
if (len(result) != 2) {
if (result.length != 2) {
throw new Error('Expected 2 list items, got ' + result.length);
}