Skip to content

Commit

Permalink
WPT: Enable xhtml tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Nov 8, 2024
1 parent a00bd4d commit f1c771c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ style_traits = { version = "0.1", package = "stylo_traits" }
style_dom = { version = "0.1", package = "stylo_dom" }
selectors = { version = "0.26", package = "stylo_selectors" }
html5ever = "0.29" # needs to match stylo markup5ever version
xml5ever = "0.20" # needs to match stylo markup5ever version
euclid = "0.22"
string_cache = "0.8.7"
atomic_refcell = "0.1.13"
Expand Down
2 changes: 1 addition & 1 deletion apps/wpt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn collect_tests(wpt_dir: &Path) -> Vec<PathBuf> {
}

for suite in suites {
for ext in ["htm", "html" /*, "xht", "xhtml"*/] {
for ext in ["htm", "html", "xht", "xhtml"] {
let pattern = format!("{}/{}/**/*.{}", wpt_dir.display(), suite, ext);

let glob_results = glob::glob(&pattern).expect("Invalid glob pattern.");
Expand Down
1 change: 1 addition & 0 deletions packages/blitz-dom/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ app_units = { workspace = true }
euclid = { workspace = true, features = ["serde"] }
atomic_refcell = { workspace = true, features = ["serde"] }
html5ever = { workspace = true }
xml5ever = { workspace = true }
string_cache ={ workspace = true }

# DioxusLabs dependencies
Expand Down
17 changes: 13 additions & 4 deletions packages/blitz-dom/src/htmlsink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,19 @@ impl DocumentHtmlParser<'_> {
net_provider: SharedProvider<Resource>,
) -> &'d mut Document {
let sink = Self::new(doc, net_provider);
html5ever::parse_document(sink, Default::default())
.from_utf8()
.read_from(&mut html.as_bytes())
.unwrap()
if html.starts_with("<?xml")
|| html.starts_with("<!DOCTYPE html PUBLIC \"-//W3C//DTD//XHTML")
{
xml5ever::driver::parse_document(sink, Default::default())
.from_utf8()
.read_from(&mut html.as_bytes())
.unwrap()
} else {
html5ever::parse_document(sink, Default::default())
.from_utf8()
.read_from(&mut html.as_bytes())
.unwrap()
}
}

#[track_caller]
Expand Down

0 comments on commit f1c771c

Please sign in to comment.