简体   繁体   English

用于Web工作者内部HTML字符串内容的类似DOM的API

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

Is there any library that could help with html string manipulation inside a web worker ? 是否有任何库可以帮助在web worker中进行html字符串操作?

What I'd like to be able to do is, inside a worker, have sizzle-type selector tool that would allow me to do things like: 我希望能够做的是,在一名工人内部,有一个嘶嘶声型的选择器工具,可以让我做以下事情:

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

, without the DOM interaction. ,没有DOM交互。

What you basically want is a pure Javascript DOM implementation on which top you could run jQuery and fellows 你基本上想要的是一个纯粹的Javascript DOM实现,你可以在其上运行jQuery和其他人

One such implementation exists for Node.js Node.js存在一种这样的实现

https://github.com/tmpvar/jsdom https://github.com/tmpvar/jsdom

It can spoof DOM window object, APIs and such. 它可以欺骗DOM窗口对象,API等。

You could take the code, rip off the Node dependencies and try to apply jQuery on the top of that inside a web worker. 您可以获取代码,剔除Node依赖项并尝试在Web worker的顶部应用jQuery。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM