fix(js): parse fragments in their insertion context
This commit is contained in:
1 parent
35fa61032b
commit
a2fd4d1735
5 files changed
+60
-47
No files matched your search
@@ -7,4 +7,4 @@ pub mod selector;
|
||||
pub mod serialize;
|
||||
|
||||
pub use tree::{Attribute, DomTree, Node, NodeData, NodeId};
|
||||
pub use tree_sink::{parse_html, parse_fragment};
|
||||
pub use tree_sink::{parse_fragment, parse_fragment_with_context, parse_html};
|
||||
@@ -243,10 +243,14 @@ pub fn parse_html(html: &str) -> DomTree {
|
||||
}
|
||||
|
||||
pub fn parse_fragment(html: &str) -> DomTree {
|
||||
use html5ever::tendril::TendrilSink;
|
||||
use html5ever::{parse_fragment, ParseOpts, QualName};
|
||||
|
||||
let context_name = QualName::new(None, ns!(html), local_name!("body"));
|
||||
parse_fragment_with_context(html, context_name)
|
||||
}
|
||||
|
||||
pub fn parse_fragment_with_context(html: &str, context_name: QualName) -> DomTree {
|
||||
use html5ever::tendril::TendrilSink;
|
||||
use html5ever::{parse_fragment, ParseOpts};
|
||||
|
||||
let tree = DomTree::new();
|
||||
parse_fragment(tree, ParseOpts::default(), context_name, vec![])
|
||||
.from_utf8()
|
||||
|
||||
Reference in new issue
Block a user