The API must be on the web-worker side, and must not depend on DOM. It is not even clear if there even is a DOM, in the case of Native UI.
Shadow DOM and selectors are tricky since they can not be used
with querySelector
. (It does not pierce shadow DOM boundries)
For this reason it is better not to rely on the querySelector
at all and have a query mechanism of a tree. A custom query
mechanism would be compatible with Native UI / WebWorkers.