Code Monkey home page Code Monkey logo

Comments (3)

zhangxianhong avatar zhangxianhong commented on August 15, 2024

在tests/traits.rs中找到了样例:

	let root = Vis::load(&html)?;
	let doc = root.document();
	assert_eq!(doc_element.unwrap().tag_name(), "HTML");

from visdom.

fefit avatar fefit commented on August 15, 2024

@zhangxianhong 抱歉,看到晚了,刚开始设计的时候,为了load操作方便,返回的是个包含root虚拟节点的Elements,所以在Elements上留了个document方法入口来返回document,通过document.document_element来返回HTML根节点。如果load的是正常的包含HTML根节点的html代码,可以通过这种方式来获取;如果是非HTML的DocumentFragement片段,就拿不到document_element了,对于这种情况,要拿到根节点,可能针对两种情况整体增加个:root伪类比较方便,后续可以添加下。

from visdom.

fefit avatar fefit commented on August 15, 2024

@zhangxianhong 新增了 :root 伪类来查找 html 根元素,一般情况下也可以通过标签名 :children("html") 来直接获取。感谢反馈!

from visdom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.