Code Monkey home page Code Monkey logo

Comments (2)

xmh0511 avatar xmh0511 commented on August 15, 2024
use visdom::{types::BoxDynError, Vis};

fn main()->Result<(),BoxDynError> {
    const HTML:&str = r#"<div><p class="item"></p></div><div></div>"#;
	let v_out = Vis::load(HTML)?;
	let p = v_out.find("p").get(0).unwrap().outer_html();
	let p_clone = Vis::load(p)?;
	let p_clone = p_clone.get(0).unwrap();
	p_clone.get_attribute("class");
	Ok(())
}

这个代码会直接panic

Element node must have a meta field.

也许与这个问题相关

from visdom.

fefit avatar fefit commented on August 15, 2024

这块的设计的确和 jQuery 不太相同,load 方法加载的可能是整个html页面,也可能是html片段,与 cheeriojs 中的 load 方法更类似。

// jquery 中解析的主要是元素节点
$("<!DOCTYPE html><html></html>").length // 0
$("<html></html>").length // 1

load 方法得到的是个虚拟根节点,根节点上实际上只能进行一些查找操作和节点修改操作,其它操作则可能会报上面的错误,当初为了操作相对方便, load 方法返回的数据类型也是 Elements,后面有时间打算把它做成单独的类型,限制下它的可操作范围,防止出现上面的操作错误了。感谢反馈建议!

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.