There seems to be an error. If there is just one “a” element on the document, this:
List := 'Array'.from(document.getElementsByTagName("a")).
returns list with one element [<js_HTMLAnchorElement>(1)]
, which is correct.
If there are more “a” elements, variable List
remains unbound.
I think the issue could be in src/wasm/prolog.js
, related to variable term
and line
rc = prolog.bindings.js_unify_obj(term, id);
In the first call (which is the last element of Array) the term
is unbound with id=1
and js_unify_obj
succeeds. The second call with the last but one element the term
is already bound to this last Array’s element and js_unify_obj
fails.