DOM-like APIs for HTML string content inside a web worker

Is there any library that could help with handling html strings inside a web worker?

What I would like to do, inside the worker, has a sizzle-type selector tool that will allow me to do things like:

hString = "<div><img src='foo'></img></div>" imgSrc = $(hString).find("img").attr("src") // foo 

without interacting with the DOM.

+4
source share
1 answer

What you basically want is a pure Javascript DOM implementation on which you can run jQuery and guys

One such implementation exists for Node.js

https://github.com/tmpvar/jsdom

It can spoof a DOM window object, API, etc.

You can take the code, break the dependencies of Node and try to apply jQuery at the top of this web worker.

+1
source

Source: https://habr.com/ru/post/944741/


All Articles