Skip to content

Runtime error when passing class attribute from Html package. #3

@jwoudenberg

Description

@jwoudenberg

When attempting to add a class name to an SVG element using class from the elm-lang/html package the compiler doesn't complain. When running the compiled program an error is thrown:

Uncaught TypeError: Cannot set property className of #<SVGElement> which has only a getter

It's a stupid mistake, but still, when working with some SVG content nested in an HTML view it's not unlikely to happen.

Below is a sample program that produces the error.

module Main exposing (..)

import Html.App as Html
import Svg exposing (..)
import Html.Attributes exposing (class)


view : () -> Svg Never
view model =
    svg []
        [ g [ class "html-class" ]
            []
        ]


main : Program Never
main =
    Html.beginnerProgram { model = (), view = view, update = \_ _ -> () }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions