Skip to content

Commit eda4c91

Browse files
authored
Don't remove namespaces from attributes (#61)
Fixes #12.
1 parent 6c05f4d commit eda4c91

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/soup.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ let from_signals' ~map_attributes signals =
100100
~element:(fun name attributes children ->
101101
let attributes =
102102
attributes
103-
|> List.map (fun ((_, n), v) -> n, v)
103+
|> List.map (fun ((ns, n), v) ->
104+
match ns with
105+
| "" -> (n, v)
106+
| _ -> (ns ^ ":" ^ n, v))
104107
|> map_attributes name in
105108
create_element (snd name) attributes children)
106109
s)

test/pages/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<html>
2-
<body class="lists">
2+
<body class="lists" my:attr="value">
33

44
<ul>
55
<li id="one" class="odd">Item 1</li>

test/test.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ let suites = [
357357
in
358358

359359
value "body" "class" (Some "lists");
360+
value "body" "my:attr" (Some "value");
360361
value "li#two" "id" (Some "two");
361362
value "html" "id" None;
362363

0 commit comments

Comments
 (0)