Skip to content

Commit b0822fe

Browse files
garybnatefaubion
authored andcommitted
Ref might not be an HTMLElement (#6)
1 parent e2845d6 commit b0822fe

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/Halogen/VDom/DOM/Prop.purs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import Data.Tuple (Tuple(..), fst, snd)
2121
import DOM (DOM)
2222
import DOM.Event.EventTarget (eventListener) as DOM
2323
import DOM.Event.Types (EventType(..), Event) as DOM
24-
import DOM.HTML.Types (HTMLElement) as DOM
2524
import DOM.Node.Types (Element) as DOM
2625
import Halogen.VDom as V
2726
import Halogen.VDom.Types (Namespace(..))
@@ -32,7 +31,7 @@ data Prop a
3231
= Attribute (Maybe Namespace) String String
3332
| Property String PropValue
3433
| Handler DOM.EventType (DOM.Event Maybe a)
35-
| Ref (ElemRef DOM.HTMLElement Maybe a)
34+
| Ref (ElemRef DOM.Element Maybe a)
3635

3736
instance functorPropFunctor Prop where
3837
map f (Handler ty g) = Handler ty (map f <$> g)
@@ -91,7 +90,7 @@ buildProp emit el = render
9190
done ps = do
9291
case StrMap.lookup "ref" ps of
9392
Just (Ref f) → do
94-
mbEmit (f (Removed (unsafeElementToHTMLElement el)))
93+
mbEmit (f (Removed el))
9594
_ → do
9695
Util.effUnit
9796

@@ -116,7 +115,7 @@ buildProp emit el = render
116115
Fn.runFn3 Util.addEventListener ty listener el
117116
pure v
118117
Ref f → do
119-
mbEmit (f (Created (unsafeElementToHTMLElement el)))
118+
mbEmit (f (Created el))
120119
pure v
121120

122121
diffProp = Fn.mkFn2 \prevEvents events → Fn.mkFn4 \_ _ v1 v2 →
@@ -173,9 +172,6 @@ propToStrKey = case _ of
173172
Handler (DOM.EventType ty) _ → "handler/" <> ty
174173
Ref _ → "ref"
175174

176-
unsafeElementToHTMLElement DOM.Element DOM.HTMLElement
177-
unsafeElementToHTMLElement = unsafeCoerce
178-
179175
setProperty eff. Fn.Fn3 String PropValue DOM.Element (Eff (dom DOM | eff) Unit)
180176
setProperty = Util.unsafeSetAny
181177

0 commit comments

Comments
 (0)