1- module Html.Parser.Util exposing (toVirtualDom , toVirtualDomSvg )
1+ module Html.Parser.Util exposing (toVirtualDom )
22
33{- | Utility functions that may help you digging into the contents.
44
55
66# Virtual DOM
77
8- @docs toVirtualDom, toVirtualDomSvg
8+ @docs toVirtualDom
99
1010-}
1111
1212import Html exposing (..)
1313import Html.Attributes exposing (..)
1414import Html.Parser exposing (Node (..) )
15- import Svg exposing (Svg )
16- import Svg.Attributes
1715import VirtualDom
1816
1917
@@ -28,11 +26,7 @@ toVirtualDomEach : Node -> Html msg
2826toVirtualDomEach node =
2927 case node of
3028 Element name attrs children ->
31- if name == " svg" then
32- toVirtualDomSvgEach node
33-
34- else
35- Html . node name ( List . map toAttribute attrs) ( toVirtualDom children)
29+ Html . node name ( List . map toAttribute attrs) ( toVirtualDom children)
3630
3731 Text s ->
3832 text s
@@ -44,45 +38,3 @@ toVirtualDomEach node =
4438toAttribute : ( String , String ) -> Attribute msg
4539toAttribute ( name, value ) =
4640 attribute name value
47-
48-
49- {- | Converts nodes to virtual dom SVG nodes.
50-
51- Note: If node list contains `<svg>` tag, you can use `toVirtualDom` instead.
52- Otherwise, use this function.
53-
54- svg : Svg msg
55- svg =
56- parse """<circle cx="40" cy="40" r="24" style="stroke:#006600; fill:#00cc00"/>"""
57- |> toVirtualDomSvg
58- |> Svg.svg []
59-
60- -}
61- toVirtualDomSvg : List Node -> List (Svg msg )
62- toVirtualDomSvg nodes =
63- List . map toVirtualDomSvgEach nodes
64-
65-
66- toVirtualDomSvgEach : Node -> Svg msg
67- toVirtualDomSvgEach node =
68- case node of
69- Element name attrs children ->
70- Svg . node name ( List . map toSvgAttribute attrs) ( toVirtualDomSvg children)
71-
72- Text s ->
73- text s
74-
75- Comment _ ->
76- text " "
77-
78-
79- toSvgAttribute : ( String , String ) -> Attribute msg
80- toSvgAttribute ( name, value ) =
81- if String . startsWith " xlink:" name then
82- VirtualDom . attributeNS " http://www.w3.org/1999/xlink" name value
83-
84- else if String . startsWith " xml:" name then
85- VirtualDom . attributeNS " http://www.w3.org/XML/1998/namespace" name value
86-
87- else
88- VirtualDom . attribute name value
0 commit comments