Skip to content

Commit

Permalink
Don't remove namespaces from attributes (#61)
Browse files Browse the repository at this point in the history
Fixes #12.
  • Loading branch information
maxRN authored Sep 5, 2024
1 parent 6c05f4d commit eda4c91
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/soup.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ let from_signals' ~map_attributes signals =
~element:(fun name attributes children ->
let attributes =
attributes
|> List.map (fun ((_, n), v) -> n, v)
|> List.map (fun ((ns, n), v) ->
match ns with
| "" -> (n, v)
| _ -> (ns ^ ":" ^ n, v))
|> map_attributes name in
create_element (snd name) attributes children)
s)
Expand Down
2 changes: 1 addition & 1 deletion test/pages/list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<html>
<body class="lists">
<body class="lists" my:attr="value">

<ul>
<li id="one" class="odd">Item 1</li>
Expand Down
1 change: 1 addition & 0 deletions test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ let suites = [
in

value "body" "class" (Some "lists");
value "body" "my:attr" (Some "value");
value "li#two" "id" (Some "two");
value "html" "id" None;

Expand Down

0 comments on commit eda4c91

Please sign in to comment.