File tree Expand file tree Collapse file tree 3 files changed +60
-1
lines changed
Expand file tree Collapse file tree 3 files changed +60
-1
lines changed Original file line number Diff line number Diff line change 11exports . nodeValue_ = function ( event ) {
2- if ( event . target . contentEditable )
2+ if ( event . target . contentEditable === true || event . target . contentEditable === "true" || event . target . contentEditable === "" )
33 return event . target . innerText ;
44
55 return event . target . value ;
Original file line number Diff line number Diff line change 1+ module Test.Basic.ContentEditable (mount ) where
2+
3+ import Prelude
4+
5+ import Effect (Effect )
6+ import Flame (QuerySelector (..), Html )
7+ import Flame.Application.NoEffects as FAN
8+ import Flame.HTML.Attribute as HA
9+ import Flame.HTML.Element as HE
10+
11+ type Model = String
12+
13+ data Message = SetModel String
14+
15+ init :: Model
16+ init = " start"
17+
18+ update :: Model -> Message -> Model
19+ update _ = case _ of
20+ SetModel newModel -> newModel
21+
22+ view :: Model -> Html Message
23+ view model = HE .main_ [
24+ HE .span " text-output" model,
25+ HE .select [HA .id " content-select" , HA .createAttribute " contentEditable" " inherit" , HA .onInput SetModel ] [
26+ HE .option [HA .value " 1" ] " 1" ,
27+ HE .option [HA .selected true , HA .value " 2" ] " 2"
28+ ],
29+ HE .div [HA .id " content-div" , HA .contentEditable true , HA .onInput SetModel ] [
30+ HE .text " content"
31+ ]
32+ ]
33+
34+ mount :: Effect Unit
35+ mount = FAN .mount_ (QuerySelector " #mount-point" ) {
36+ init,
37+ update,
38+ view
39+ }
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import Effect.Class (liftEffect)
1515import Flame.Application.DOM as FAD
1616import Flame.Application.Effectful as FAE
1717import Flame.HTML.Attribute as HA
18+ import Test.Basic.ContentEditable as TBC
1819import Flame.HTML.Element as HE
1920import Flame.Renderer.String as FRS
2021import Partial.Unsafe (unsafePartial )
@@ -309,6 +310,25 @@ main =
309310 TUA .equal false currentNewChecked
310311 TUA .equal false currentNewDisabled
311312
313+ test " contentEditable" do
314+ -- contentEditable is not supported by jsdom
315+ liftEffect do
316+ unsafeCreateEnviroment
317+ TBC .mount
318+ childrenLength <- childrenNodeLength
319+ TUA .equal 3 childrenLength
320+
321+ initialOutput <- textContent " #text-output"
322+ TUA .equal " start" initialOutput
323+
324+ dispatchEvent inputEvent " #content-div"
325+ currentOutput <- textContent " #text-output"
326+ TUA .equal " " currentOutput
327+
328+ dispatchEvent inputEvent " #content-select"
329+ currentOutput2 <- textContent " #text-output"
330+ TUA .equal " 2" currentOutput2
331+
312332 suite " Effectful specific" do
313333 test " slower effects" do
314334 liftEffect do
You can’t perform that action at this time.
0 commit comments