-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
缺少类似jquery的clone #21
Comments
use visdom::{types::BoxDynError, Vis};
fn main()->Result<(),BoxDynError> {
const HTML:&str = r#"<div id="contain"><p class="item"></p></div>"#;
let v = Vis::load(HTML)?;
let p = v.find("p").get(0).unwrap().cloned();
let mut p_clone = Vis::dom(&p);
p_clone.set_text("abc");
//v.find("#contain").append(& mut p_clone);
println!("{}",v.outer_html());
Ok(())
} 输出:
期望行为:提供deep clone方法对拷贝的对象的dom的操作不影响拷贝源dom. |
@xmh0511 的确 |
也许叫 |
命名实在有点头大,想的是以后如果更新大版本直接把当前版本node节点的 const HTML:&str = r#"<div id="contain"><p class="item"></p></div>"#;
let v = Vis::load(HTML)?;
let p = v.find("p");
let mut p_clone = p.clone();
p_clone.set_text("abc");
assert_eq!(p.text(), "");
assert_eq!(p_clone.text(), "abc");
Ok(()) 感谢建议与反馈~! |
@fefit 我认为visdom里面所有类型提供的 |
嗯,后续如果做大版本迭代会保持这种方式了~ |
测试中发现,好像没有提供jquery中对某个元素拷贝的接口,目前的
cloned
不是深拷贝,对返回的值进行操作依然会作用到之前的元素上The text was updated successfully, but these errors were encountered: