Skip to content

Commit

Permalink
Adjust SVG attributes irrespective of their namespace (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
maurobringolf committed Jul 13, 2023
1 parent 9afbf57 commit 70106f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/html_parser.ml
Expand Up @@ -319,8 +319,6 @@ struct

let adjust_svg_attributes attributes =
attributes |> List.map (fun ((ns, name), value) ->
if ns <> svg_ns then (ns, name), value
else
let name =
match name with
| "attributename" -> "attributeName"
Expand Down
13 changes: 13 additions & 0 deletions test/test_html_parser.ml
Expand Up @@ -811,6 +811,19 @@ let tests = [
1, 29, S `End_element;
1, 29, S `End_element]);

("html.parser.foreign.attribute" >:: fun _ ->
expect "<body><svg refX=\"\"><g/></svg></body>"
[ 1, 1, S (start_element "html");
1, 1, S (start_element "head");
1, 1, S `End_element;
1, 1, S (start_element "body");
1, 7, S (`Start_element ((svg_ns, "svg"), [("", "refX"), ""]));
1, 20, S (`Start_element ((svg_ns, "g"), []));
1, 20, S `End_element;
1, 24, S `End_element;
1, 37, S `End_element;
1, 37, S `End_element]);

("html.parser.foreign.svg-followed-by-html" >:: fun _ ->
expect ~context:(Some (`Fragment "body"))
"<svg><feTile></feTile></svg><b></b>"
Expand Down

0 comments on commit 70106f8

Please sign in to comment.