unjquerify
unjquerify copied to clipboard
Collection collectors are not always correct
For functions that cause mutations, the current approach of translating $("a").hide()
to document.querySelectorAll("a").forEach(e => e.style.display = "none");
is possible, but functions that return values will not be transformed as expected.
Consider the following cases:
-
const a = $("a").css("font-size");
- The documentation specifies that the value of the first element in the collection is returned. -
const t = $("a").matches(".active");
- The documentation specifies that the value should betrue
if one of the elements matches the selector. - There could be more collectors.
Therefore, the current forEach
approach does not work for all cases.
Each transformation should be augmented with a transformation that should be used to collect the results of an application to a collection.