Skip to content

Instantly share code, notes, and snippets.

/Main.elm Secret

Created November 25, 2016 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6c0bd25ee883f945e1c6365316fb07d3 to your computer and use it in GitHub Desktop.
Save anonymous/6c0bd25ee883f945e1c6365316fb07d3 to your computer and use it in GitHub Desktop.
xlink:href breaking the elm virtual dom diffing?
import Html exposing (Html)
import Svg exposing (..)
import Svg.Attributes exposing (..)
import VirtualDom exposing (attributeNS)
import AnimationFrame
import Time exposing (Time)
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}
-- MODEL
type alias Model = Time
init : (Model, Cmd Msg)
init =
(0, Cmd.none)
-- UPDATE
type Msg
= Tick Time
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
Tick newTime ->
(0, Cmd.none)
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
AnimationFrame.times Tick
-- VIEW
view : Model -> Html Msg
view model =
let
justCirc = [ circle [cx "50", cy "50", r "40", strokeWidth "8", stroke "red", fill "red"] [] ]
symAndUse =
[ symbol [id "sym01"] justCirc
, use [xlinkHref "#sym01", x "0", y "0", width "100", height "100"] []
]
in
svg [ viewBox "0 0 200 200", width "600px" ]
--justCirc
symAndUse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment