HtmlIssue215TextareaTypeOnPatchTest
Tags:elm19-bug
Issue: elm/html#215
Adding `type_` to an existing `textarea` throws when the view is patched. <https://github.com/elm/html/issues/215> The second variant in the issue: the first view renders a plain `textarea`, and the next one adds `type_ "text"`. A `<textarea>`'s `type` property has only a getter, so the patch throws (Elm's code is strict). Elm 0.19.1 (elm/virtual-dom 1.0.5) crashes rendering step 1, so step 2 is never reached; the program should keep running.
Results
elm-0.19.1
failran in 121 msexit 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.
step: 1
/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:2865
((key !== 'value' && key !== 'checked') || domNode[key] !== value) && (domNode[key] = value);
^
TypeError: Cannot set property type of #<Node> which has only a getter
at _VirtualDom_applyFacts (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:2865:87)
at _VirtualDom_applyPatch (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3742:4)
at _VirtualDom_applyPatchesHelp (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3725:17)
at _VirtualDom_applyPatches (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3716:9)
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3971:15
at Timeout.updateIfNeeded [as _onTimeout] (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:4040:56)
at listOnTimeout (node:internal/timers:585:17)
at process.processTimers (node:internal/timers:521:7)
Node.js v22.23.5
elm-0.19.2
failran in 104 msexit 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.
step: 1
/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:2865
((key !== 'value' && key !== 'checked') || domNode[key] !== value) && (domNode[key] = value);
^
TypeError: Cannot set property type of #<Node> which has only a getter
at _VirtualDom_applyFacts (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:2865:87)
at _VirtualDom_applyPatch (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3742:4)
at _VirtualDom_applyPatchesHelp (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3725:17)
at _VirtualDom_applyPatches (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3716:9)
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3971:15
at Timeout.updateIfNeeded [as _onTimeout] (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:4040:56)
at listOnTimeout (node:internal/timers:585:17)
at process.processTimers (node:internal/timers:521:7)
Node.js v22.23.5
elm-0.19.3
failran in 116 msexit 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.
step: 1
/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:2865
((key !== 'value' && key !== 'checked') || domNode[key] !== value) && (domNode[key] = value);
^
TypeError: Cannot set property type of #<Node> which has only a getter
at _VirtualDom_applyFacts (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:2865:87)
at _VirtualDom_applyPatch (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3742:4)
at _VirtualDom_applyPatchesHelp (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3725:17)
at _VirtualDom_applyPatches (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3716:9)
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:3971:15
at Timeout.updateIfNeeded [as _onTimeout] (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-html/out/HtmlIssue215TextareaTypeOnPatchTest.js:4040:56)
at listOnTimeout (node:internal/timers:585:17)
at process.processTimers (node:internal/timers:521:7)
Node.js v22.23.5
lamdera-1.5.0
passran in 164 msOutput
step: 1 step: 2
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-html/HtmlIssue215TextareaTypeOnPatchTest] in its title.
Source
The -- CHECK: lines give the expected output.
module HtmlIssue215TextareaTypeOnPatchTest exposing (main)
{-| Adding `type_` to an existing `textarea` throws when the view is patched.
<https://github.com/elm/html/issues/215>
The second variant in the issue: the first view renders a plain `textarea`, and the next one
adds `type_ "text"`. A `<textarea>`'s `type` property has only a getter, so the patch throws
(Elm's code is strict). Elm 0.19.1 (elm/virtual-dom 1.0.5) crashes rendering step 1, so step 2
is never 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 (type_)
import Process
import Task
view : Int -> Html Int
view step =
if step == 0 then
Html.textarea [] []
else
Html.textarea [ type_ "text" ] []
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
}