Elm Exactly
Results / elm-html /

HtmlIssue251EmptyAttributeNameTest

Tags:elm19-bug

elm-0.19.1 failelm-0.19.2 failelm-0.19.3 faillamdera-1.5.0 fail

Issue: elm/html#251

`Html.Attributes.attribute ""` throws at run time.

<https://github.com/elm/html/issues/251>

elm/virtual-dom passes the name to `setAttribute`, which throws an InvalidCharacterError for a
name that is not a valid attribute name, such as the empty string. Elm 0.19.1
(elm/virtual-dom 1.0.5) crashes on the first render, so no step is reached; the program should
keep running.

Results

elm-0.19.1

failran in 39 ms
exit code 1, expected 0
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:28
        throw new DOMException("Failed to execute '" + method + "' on 'Element': '" + name +
        ^

DOMException [InvalidCharacterError]: Failed to execute 'setAttribute' on 'Element': '' is not a valid attribute name.
    at new DOMException (node:internal/per_context/domexception:76:18)
    at checkAttributeName (/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:28:15)
    at Node.setAttribute (/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:85:32)
    at _VirtualDom_applyAttrs (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:2895:14)
    at _VirtualDom_applyFacts (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:2860:6)
    at _VirtualDom_render (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:2832:2)
    at _VirtualDom_applyPatchRedraw (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3812:16)
    at _VirtualDom_applyPatch (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3739:11)
    at _VirtualDom_applyPatchesHelp (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3725:17)
    at _VirtualDom_applyPatches (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3716:9)

Node.js v22.23.5

elm-0.19.2

failran in 37 ms
exit code 1, expected 0
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:28
        throw new DOMException("Failed to execute '" + method + "' on 'Element': '" + name +
        ^

DOMException [InvalidCharacterError]: Failed to execute 'setAttribute' on 'Element': '' is not a valid attribute name.
    at new DOMException (node:internal/per_context/domexception:76:18)
    at checkAttributeName (/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:28:15)
    at Node.setAttribute (/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:85:32)
    at _VirtualDom_applyAttrs (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:2895:14)
    at _VirtualDom_applyFacts (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:2860:6)
    at _VirtualDom_render (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:2832:2)
    at _VirtualDom_applyPatchRedraw (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3812:16)
    at _VirtualDom_applyPatch (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3739:11)
    at _VirtualDom_applyPatchesHelp (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3725:17)
    at _VirtualDom_applyPatches (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3716:9)

Node.js v22.23.5

elm-0.19.3

failran in 39 ms
exit code 1, expected 0
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:28
        throw new DOMException("Failed to execute '" + method + "' on 'Element': '" + name +
        ^

DOMException [InvalidCharacterError]: Failed to execute 'setAttribute' on 'Element': '' is not a valid attribute name.
    at new DOMException (node:internal/per_context/domexception:76:18)
    at checkAttributeName (/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:28:15)
    at Node.setAttribute (/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:85:32)
    at _VirtualDom_applyAttrs (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:2895:14)
    at _VirtualDom_applyFacts (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:2860:6)
    at _VirtualDom_render (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:2832:2)
    at _VirtualDom_applyPatchRedraw (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3812:16)
    at _VirtualDom_applyPatch (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3739:11)
    at _VirtualDom_applyPatchesHelp (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3725:17)
    at _VirtualDom_applyPatches (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3716:9)

Node.js v22.23.5

lamdera-1.5.0

failran in 42 ms
exit code 1, expected 0
--- output ---
/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:28
        throw new DOMException("Failed to execute '" + method + "' on 'Element': '" + name +
        ^

DOMException [InvalidCharacterError]: Failed to execute 'setAttribute' on 'Element': '' is not a valid attribute name.
    at new DOMException (node:internal/per_context/domexception:76:18)
    at checkAttributeName (/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:28:15)
    at Node.setAttribute (/home/runner/work/elm-test-suite/elm-test-suite/runner/dom.js:85:32)
    at _VirtualDom_applyAttrs (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3764:12)
    at _VirtualDom_applyFacts (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3611:3)
    at _VirtualDom_render (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:3514:2)
    at _VirtualDom_applyPatchRedraw (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:4594:16)
    at _VirtualDom_diffHelp (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:4043:11)
    at _VirtualDom_applyPatches (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:4567:19)
    at /home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-html/out/HtmlIssue251EmptyAttributeNameTest.js:5070:16

Node.js v22.23.5

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-html/HtmlIssue251EmptyAttributeNameTest] in its title.

Source

The -- CHECK: lines give the expected output.

module HtmlIssue251EmptyAttributeNameTest exposing (main)
{-| `Html.Attributes.attribute ""` throws at run time.
<https://github.com/elm/html/issues/251>
elm/virtual-dom passes the name to `setAttribute`, which throws an InvalidCharacterError for a
name that is not a valid attribute name, such as the empty string. Elm 0.19.1
(elm/virtual-dom 1.0.5) crashes on the first render, so no step is reached; the program should
keep running.
-}
-- TAGS: elm19-bug
-- CHECK: step: 1
-- CHECK: step: 2
import Browser
import Html exposing (Html)
import Html.Attributes exposing (attribute)
import Process
import Task
view : Int -> Html Int
view step =
Html.div [ attribute "" "x" ] []
next : Int -> Cmd Int
next step =
Task.perform (\_ -> step + 1) (Process.sleep 50)
main : Program () Int Int
main =
Browser.element
{ init = \_ -> ( 0, next 0 )
, view = view
, update =
\step _ ->
( Debug.log "step" step
, if step < 2 then
next step
else
Cmd.none
)
, subscriptions = \_ -> Sub.none
}