js-on-sx: call/apply substitute global for null/undefined this (non-strict)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s

This commit is contained in:
2026-05-09 11:33:23 +00:00
parent b59f08a1b8
commit 4481f5f98b
2 changed files with 11 additions and 4 deletions

View File

@@ -333,20 +333,25 @@
(cond
((= key "call")
(let
((this-arg (if (< (len args) 1) :js-undefined (nth args 0)))
((raw-this (if (< (len args) 1) :js-undefined (nth args 0)))
(rest
(if
(< (len args) 1)
(list)
(js-list-slice args 1 (len args)))))
(js-call-with-this this-arg recv rest)))
(let
((this-arg
(if (or (js-undefined? raw-this) (= raw-this nil)) js-global-this raw-this)))
(js-call-with-this this-arg recv rest))))
((= key "apply")
(let
((this-arg (if (< (len args) 1) :js-undefined (nth args 0)))
((raw-this (if (< (len args) 1) :js-undefined (nth args 0)))
(arr
(if (< (len args) 2) (list) (nth args 1))))
(let
((rest (cond ((= arr nil) (list)) ((js-undefined? arr) (list)) ((list? arr) arr) (else (js-iterable-to-list arr)))))
((rest (cond ((= arr nil) (list)) ((js-undefined? arr) (list)) ((list? arr) arr) (else (js-iterable-to-list arr))))
(this-arg
(if (or (js-undefined? raw-this) (= raw-this nil)) js-global-this raw-this)))
(js-call-with-this this-arg recv rest))))
((= key "bind")
(let