├── .gitignore ├── package.json ├── .travis.yml ├── src └── DOM │ └── Classy │ ├── Util.purs │ ├── Event.purs │ ├── Event │ └── EventTarget.purs │ ├── ParentNode.purs │ ├── Element.purs │ ├── HTMLElement.purs │ └── Node.purs ├── bower.json ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /.* 2 | !/.gitignore 3 | !/.travis.yml 4 | /bower_components/ 5 | /node_modules/ 6 | /output/ 7 | package-lock.json 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "clean": "rimraf output && rimraf .pulp-cache", 5 | "build": "pulp build -- --censor-lib --strict" 6 | }, 7 | "devDependencies": { 8 | "pulp": "^11.0.0", 9 | "purescript": "^0.11.3", 10 | "purescript-psa": "^0.5.1", 11 | "rimraf": "^2.6.1" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | dist: trusty 3 | sudo: required 4 | node_js: stable 5 | install: 6 | - npm install -g bower 7 | - npm install 8 | - bower install 9 | script: 10 | - npm run -s build 11 | after_success: 12 | - >- 13 | test $TRAVIS_TAG && 14 | echo $GITHUB_TOKEN | pulp login && 15 | echo y | pulp publish --no-push 16 | -------------------------------------------------------------------------------- /src/DOM/Classy/Util.purs: -------------------------------------------------------------------------------- 1 | module DOM.Classy.Util where 2 | 3 | import Prelude 4 | 5 | import Control.Monad.Except (runExcept) 6 | 7 | import Data.Either (either) 8 | import Data.Foreign (F, Foreign) 9 | import Data.Maybe (Maybe(..)) 10 | 11 | import Unsafe.Coerce (unsafeCoerce) 12 | 13 | fromAny :: forall n a. (Foreign -> F n) -> a -> Maybe n 14 | fromAny f = either (const Nothing) Just <<< runExcept <<< unsafeCoerce f 15 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "purescript-dom-classy", 3 | "homepage": "https://github.com/garyb/purescript-dom-classy", 4 | "license": "MIT", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/garyb/purescript-dom-classy.git" 8 | }, 9 | "ignore": [ 10 | "**/.*", 11 | "bower_components", 12 | "node_modules", 13 | "output", 14 | "bower.json", 15 | "package.json" 16 | ], 17 | "dependencies": { 18 | "purescript-dom": "^4.1.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # purescript-dom-classy 2 | 3 | [![Latest release](http://img.shields.io/github/release/garyb/purescript-dom-classy.svg)](https://github.com/garyb/purescript-dom-classy/releases) 4 | [![Build status](https://travis-ci.org/garyb/purescript-dom-classy.svg?branch=master)](https://travis-ci.org/garyb/purescript-dom-classy) 5 | 6 | A library providing typeclasses to make working with the DOM more pleasant. 7 | 8 | There's plenty of room for improvement, suggestions and additions are very welcome! 9 | 10 | ## Installation 11 | 12 | ``` 13 | bower install purescript-dom-classy 14 | ``` 15 | 16 | ## Documentation 17 | 18 | - Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-dom-classy). 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Gary Burgess 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /src/DOM/Classy/Event.purs: -------------------------------------------------------------------------------- 1 | module DOM.Classy.Event where 2 | 3 | import Prelude 4 | 5 | import Control.Monad.Eff (Eff) 6 | 7 | import Data.Maybe (Maybe(..)) 8 | 9 | import DOM (DOM) 10 | import DOM.Classy.Util (fromAny) 11 | import DOM.Event.Event as EE 12 | import DOM.Event.EventPhase (EventPhase) 13 | import DOM.Event.Types as E 14 | import DOM.HTML.Event.Types as HE 15 | import DOM.Node.Types (Node) 16 | import DOM.Websocket.Event.Types as WS 17 | 18 | -- | A class for subtypes of `Event`. 19 | class IsEvent e where 20 | toEvent :: e -> E.Event 21 | fromEvent :: E.Event -> Maybe e 22 | 23 | -- | The event type. 24 | type_ :: forall e. IsEvent e => e -> E.EventType 25 | type_ = EE.type_ <<< toEvent 26 | 27 | -- | The element that was the source of the event. 28 | target :: forall e. IsEvent e => e -> Node 29 | target = EE.target <<< toEvent 30 | 31 | -- | The element that the event listener was added to. 32 | currentTarget :: forall e. IsEvent e => e -> Node 33 | currentTarget = EE.currentTarget <<< toEvent 34 | 35 | -- | Indicates which phase of the event flow that is currently being processed 36 | -- | for the event. 37 | eventPhase :: forall e. IsEvent e => Partial => e -> EventPhase 38 | eventPhase = EE.eventPhase <<< toEvent 39 | 40 | -- | The integer value for the current event phase. 41 | eventPhaseIndex :: forall e. IsEvent e => e -> Int 42 | eventPhaseIndex = EE.eventPhaseIndex <<< toEvent 43 | 44 | -- | Prevents the event from bubbling up to futher event listeners. Other event 45 | -- | listeners on the current target will still fire. 46 | stopPropagation :: forall e eff. IsEvent e => e -> Eff (dom :: DOM | eff) Unit 47 | stopPropagation = EE.stopPropagation <<< toEvent 48 | 49 | -- | Prevents all other listeners for the event from being called. This includes 50 | -- | event listeners added to the current target after the current listener. 51 | stopImmediatePropagation :: forall e eff. IsEvent e => e -> Eff (dom :: DOM | eff) Unit 52 | stopImmediatePropagation = EE.stopImmediatePropagation <<< toEvent 53 | 54 | -- | Indicates whether the event will bubble up through the DOM or not. 55 | bubbles :: forall e. IsEvent e => e -> Boolean 56 | bubbles = EE.bubbles <<< toEvent 57 | 58 | -- | Indicates whether the event can be cancelled. 59 | cancelable :: forall e. IsEvent e => e -> Boolean 60 | cancelable = EE.cancelable <<< toEvent 61 | 62 | -- | Cancels the event if it can be cancelled. 63 | preventDefault :: forall e eff. IsEvent e => e -> Eff (dom :: DOM | eff) Unit 64 | preventDefault = EE.preventDefault <<< toEvent 65 | 66 | -- | Indicates whether `preventDefault` was called on the event. 67 | defaultPrevented :: forall e. IsEvent e => e -> Boolean 68 | defaultPrevented = EE.defaultPrevented <<< toEvent 69 | 70 | -- | The time in milliseconds between 01/01/1970 and when the event was 71 | -- | dispatched. 72 | timeStamp :: forall e. IsEvent e => e -> Number 73 | timeStamp = EE.timeStamp <<< toEvent 74 | 75 | instance isEventEvent :: IsEvent E.Event where 76 | toEvent = id 77 | fromEvent = Just 78 | 79 | instance isEventCustomEvent :: IsEvent E.CustomEvent where 80 | toEvent = E.customEventToEvent 81 | fromEvent = fromAny E.readCustomEvent 82 | 83 | instance isEventUIEvent :: IsEvent E.UIEvent where 84 | toEvent = E.uiEventToEvent 85 | fromEvent = fromAny E.readUIEvent 86 | 87 | instance isEventFocusEvent :: IsEvent E.FocusEvent where 88 | toEvent = E.focusEventToEvent 89 | fromEvent = fromAny E.readFocusEvent 90 | 91 | instance isEventMouseEvent :: IsEvent E.MouseEvent where 92 | toEvent = E.mouseEventToEvent 93 | fromEvent = fromAny E.readMouseEvent 94 | 95 | instance isEventWheelEvent :: IsEvent E.WheelEvent where 96 | toEvent = E.wheelEventToEvent 97 | fromEvent = fromAny E.readWheelEvent 98 | 99 | instance isEventTouchEvent :: IsEvent E.TouchEvent where 100 | toEvent = E.touchEventToEvent 101 | fromEvent = fromAny E.readTouchEvent 102 | 103 | instance isEventInputEvent :: IsEvent E.InputEvent where 104 | toEvent = E.inputEventToEvent 105 | fromEvent = fromAny E.readInputEvent 106 | 107 | instance isEventKeyboardEvent :: IsEvent E.KeyboardEvent where 108 | toEvent = E.keyboardEventToEvent 109 | fromEvent = fromAny E.readKeyboardEvent 110 | 111 | instance isEventCompositionEvent :: IsEvent E.CompositionEvent where 112 | toEvent = E.compositionEventToEvent 113 | fromEvent = fromAny E.readCompositionEvent 114 | 115 | instance isEventProgressEvent :: IsEvent E.ProgressEvent where 116 | toEvent = E.progressEventToEvent 117 | fromEvent = fromAny E.readProgressEvent 118 | 119 | instance isEventDragEvent :: IsEvent HE.DragEvent where 120 | toEvent = HE.dragEventToEvent 121 | fromEvent = fromAny HE.readDragEvent 122 | 123 | instance isEventErrorEvent :: IsEvent HE.ErrorEvent where 124 | toEvent = HE.errorEventToEvent 125 | fromEvent = fromAny HE.readErrorEvent 126 | 127 | instance isEventHashChangeEvent :: IsEvent HE.HashChangeEvent where 128 | toEvent = HE.hashChangeEventToEvent 129 | fromEvent = fromAny HE.readHashChangeEvent 130 | 131 | instance isEventCloseEvent :: IsEvent WS.CloseEvent where 132 | toEvent = WS.closeEventToEvent 133 | fromEvent = fromAny WS.readCloseEvent 134 | 135 | instance isEventMessageEvent :: IsEvent WS.MessageEvent where 136 | toEvent = WS.messageEventToEvent 137 | fromEvent = fromAny WS.readMessageEvent 138 | -------------------------------------------------------------------------------- /src/DOM/Classy/Event/EventTarget.purs: -------------------------------------------------------------------------------- 1 | module DOM.Classy.Event.EventTarget 2 | ( class EventTarget 3 | , toEventTarget 4 | , eventListener 5 | , addEventListener 6 | , removeEventListener 7 | , dispatchEvent 8 | , module Exports 9 | ) where 10 | 11 | import Prelude 12 | 13 | import Control.Monad.Eff (Eff) 14 | import Control.Monad.Eff.Exception (EXCEPTION) 15 | import DOM (DOM) 16 | import DOM.Classy.Event (class IsEvent, fromEvent, toEvent) 17 | import DOM.Event.EventTarget (EventListener) as Exports 18 | import DOM.Event.EventTarget as E 19 | import DOM.Event.Types (EventTarget, EventType) 20 | import DOM.HTML.Types as H 21 | import DOM.Node.Types as N 22 | import Data.Maybe (maybe) 23 | import Data.Monoid (mempty) 24 | import Unsafe.Coerce as U 25 | 26 | -- | A class for subtypes of `EventTarget`. 27 | class EventTarget t where 28 | toEventTarget :: t -> EventTarget 29 | 30 | -- | Creates an event listener from a normal `Eff`-based callback function, 31 | -- | automatically converting to an event subtype. If the conversion fails due 32 | -- | to a received event not matching the expected type it will be ignored. 33 | eventListener 34 | :: forall event eff a 35 | . IsEvent event 36 | => (event -> Eff eff a) 37 | -> E.EventListener eff 38 | eventListener handler = 39 | E.eventListener (maybe mempty (void <<< handler) <<< fromEvent) 40 | 41 | -- | Adds a listener to an event target. The boolean argument indicates whether 42 | -- | the listener should be added for the "capture" phase. 43 | addEventListener 44 | :: forall t eff 45 | . EventTarget t 46 | => EventType 47 | -> E.EventListener (dom :: DOM | eff) 48 | -> Boolean 49 | -> t 50 | -> Eff (dom :: DOM | eff) Unit 51 | addEventListener eventType listener capture = 52 | E.addEventListener eventType listener capture <<< toEventTarget 53 | 54 | -- | Removes a listener to an event target. The boolean argument indicates 55 | -- | whether the listener should be removed for the "capture" phase. 56 | removeEventListener 57 | :: forall t eff 58 | . EventTarget t 59 | => EventType 60 | -> E.EventListener (dom :: DOM | eff) 61 | -> Boolean 62 | -> t 63 | -> Eff (dom :: DOM | eff) Unit 64 | removeEventListener eventType listener capture = 65 | E.removeEventListener eventType listener capture <<< toEventTarget 66 | 67 | -- | Dispatches an event from an event target. 68 | dispatchEvent 69 | :: forall t event eff 70 | . EventTarget t 71 | => IsEvent event 72 | => event 73 | -> t 74 | -> Eff (dom :: DOM, err :: EXCEPTION | eff) Boolean 75 | dispatchEvent event = 76 | E.dispatchEvent (toEvent event) <<< toEventTarget 77 | 78 | instance eventTargetNode :: EventTarget N.Node where 79 | toEventTarget = U.unsafeCoerce 80 | 81 | instance eventTargetDocument :: EventTarget N.Document where 82 | toEventTarget = U.unsafeCoerce 83 | 84 | instance eventTargetElement :: EventTarget N.Element where 85 | toEventTarget = U.unsafeCoerce 86 | 87 | instance eventTargetCharacterData :: EventTarget N.CharacterData where 88 | toEventTarget = U.unsafeCoerce 89 | 90 | instance eventTargetText :: EventTarget N.Text where 91 | toEventTarget = U.unsafeCoerce 92 | 93 | instance eventTargetComment :: EventTarget N.Comment where 94 | toEventTarget = U.unsafeCoerce 95 | 96 | instance eventTargetProcessingInstruction :: EventTarget N.ProcessingInstruction where 97 | toEventTarget = U.unsafeCoerce 98 | 99 | instance eventTargetDocumentFragment :: EventTarget N.DocumentFragment where 100 | toEventTarget = U.unsafeCoerce 101 | 102 | instance eventTargetDocumentType :: EventTarget N.DocumentType where 103 | toEventTarget = U.unsafeCoerce 104 | 105 | instance eventTargetWindow :: EventTarget H.Window where 106 | toEventTarget = U.unsafeCoerce 107 | 108 | instance eventTargetHTMLDocument :: EventTarget H.HTMLDocument where 109 | toEventTarget = U.unsafeCoerce 110 | 111 | instance eventTargetHTMLElement :: EventTarget H.HTMLElement where 112 | toEventTarget = U.unsafeCoerce 113 | 114 | instance eventTargetHTMLHtmlElement :: EventTarget H.HTMLHtmlElement where 115 | toEventTarget = U.unsafeCoerce 116 | 117 | instance eventTargetHTMLHeadElement :: EventTarget H.HTMLHeadElement where 118 | toEventTarget = U.unsafeCoerce 119 | 120 | instance eventTargetHTMLTitleElement :: EventTarget H.HTMLTitleElement where 121 | toEventTarget = U.unsafeCoerce 122 | 123 | instance eventTargetHTMLBaseElement :: EventTarget H.HTMLBaseElement where 124 | toEventTarget = U.unsafeCoerce 125 | 126 | instance eventTargetHTMLLinkElement :: EventTarget H.HTMLLinkElement where 127 | toEventTarget = U.unsafeCoerce 128 | 129 | instance eventTargetHTMLMetaElement :: EventTarget H.HTMLMetaElement where 130 | toEventTarget = U.unsafeCoerce 131 | 132 | instance eventTargetHTMLStyleElement :: EventTarget H.HTMLStyleElement where 133 | toEventTarget = U.unsafeCoerce 134 | 135 | instance eventTargetHTMLBodyElement :: EventTarget H.HTMLBodyElement where 136 | toEventTarget = U.unsafeCoerce 137 | 138 | instance eventTargetHTMLHeadingElement :: EventTarget H.HTMLHeadingElement where 139 | toEventTarget = U.unsafeCoerce 140 | 141 | instance eventTargetHTMLParagraphElement :: EventTarget H.HTMLParagraphElement where 142 | toEventTarget = U.unsafeCoerce 143 | 144 | instance eventTargetHTMLHRElement :: EventTarget H.HTMLHRElement where 145 | toEventTarget = U.unsafeCoerce 146 | 147 | instance eventTargetHTMLPreElement :: EventTarget H.HTMLPreElement where 148 | toEventTarget = U.unsafeCoerce 149 | 150 | instance eventTargetHTMLQuoteElement :: EventTarget H.HTMLQuoteElement where 151 | toEventTarget = U.unsafeCoerce 152 | 153 | instance eventTargetHTMLOListElement :: EventTarget H.HTMLOListElement where 154 | toEventTarget = U.unsafeCoerce 155 | 156 | instance eventTargetHTMLUListElement :: EventTarget H.HTMLUListElement where 157 | toEventTarget = U.unsafeCoerce 158 | 159 | instance eventTargetHTMLLIElement :: EventTarget H.HTMLLIElement where 160 | toEventTarget = U.unsafeCoerce 161 | 162 | instance eventTargetHTMLDListElement :: EventTarget H.HTMLDListElement where 163 | toEventTarget = U.unsafeCoerce 164 | 165 | instance eventTargetHTMLDivElement :: EventTarget H.HTMLDivElement where 166 | toEventTarget = U.unsafeCoerce 167 | 168 | instance eventTargetHTMLAnchorElement :: EventTarget H.HTMLAnchorElement where 169 | toEventTarget = U.unsafeCoerce 170 | 171 | instance eventTargetHTMLDataElement :: EventTarget H.HTMLDataElement where 172 | toEventTarget = U.unsafeCoerce 173 | 174 | instance eventTargetHTMLTimeElement :: EventTarget H.HTMLTimeElement where 175 | toEventTarget = U.unsafeCoerce 176 | 177 | instance eventTargetHTMLSpanElement :: EventTarget H.HTMLSpanElement where 178 | toEventTarget = U.unsafeCoerce 179 | 180 | instance eventTargetHTMLBRElement :: EventTarget H.HTMLBRElement where 181 | toEventTarget = U.unsafeCoerce 182 | 183 | instance eventTargetHTMLModElement :: EventTarget H.HTMLModElement where 184 | toEventTarget = U.unsafeCoerce 185 | 186 | instance eventTargetHTMLImageElement :: EventTarget H.HTMLImageElement where 187 | toEventTarget = U.unsafeCoerce 188 | 189 | instance eventTargetHTMLIFrameElement :: EventTarget H.HTMLIFrameElement where 190 | toEventTarget = U.unsafeCoerce 191 | 192 | instance eventTargetHTMLEmbedElement :: EventTarget H.HTMLEmbedElement where 193 | toEventTarget = U.unsafeCoerce 194 | 195 | instance eventTargetHTMLObjectElement :: EventTarget H.HTMLObjectElement where 196 | toEventTarget = U.unsafeCoerce 197 | 198 | instance eventTargetHTMLParamElement :: EventTarget H.HTMLParamElement where 199 | toEventTarget = U.unsafeCoerce 200 | 201 | instance eventTargetHTMLMediaElement :: EventTarget H.HTMLMediaElement where 202 | toEventTarget = U.unsafeCoerce 203 | 204 | instance eventTargetHTMLAudioElement :: EventTarget H.HTMLAudioElement where 205 | toEventTarget = U.unsafeCoerce 206 | 207 | instance eventTargetHTMLVideoElement :: EventTarget H.HTMLVideoElement where 208 | toEventTarget = U.unsafeCoerce 209 | 210 | instance eventTargetHTMLSourceElement :: EventTarget H.HTMLSourceElement where 211 | toEventTarget = U.unsafeCoerce 212 | 213 | instance eventTargetHTMLTrackElement :: EventTarget H.HTMLTrackElement where 214 | toEventTarget = U.unsafeCoerce 215 | 216 | instance eventTargetHTMLMapElement :: EventTarget H.HTMLMapElement where 217 | toEventTarget = U.unsafeCoerce 218 | 219 | instance eventTargetHTMLAreaElement :: EventTarget H.HTMLAreaElement where 220 | toEventTarget = U.unsafeCoerce 221 | 222 | instance eventTargetHTMLTableElement :: EventTarget H.HTMLTableElement where 223 | toEventTarget = U.unsafeCoerce 224 | 225 | instance eventTargetHTMLTableCaptionElement :: EventTarget H.HTMLTableCaptionElement where 226 | toEventTarget = U.unsafeCoerce 227 | 228 | instance eventTargetHTMLTableColElement :: EventTarget H.HTMLTableColElement where 229 | toEventTarget = U.unsafeCoerce 230 | 231 | instance eventTargetHTMLTableSectionElement :: EventTarget H.HTMLTableSectionElement where 232 | toEventTarget = U.unsafeCoerce 233 | 234 | instance eventTargetHTMLTableRowElement :: EventTarget H.HTMLTableRowElement where 235 | toEventTarget = U.unsafeCoerce 236 | 237 | instance eventTargetHTMLTableCellElement :: EventTarget H.HTMLTableCellElement where 238 | toEventTarget = U.unsafeCoerce 239 | 240 | instance eventTargetHTMLTableDataCellElement :: EventTarget H.HTMLTableDataCellElement where 241 | toEventTarget = U.unsafeCoerce 242 | 243 | instance eventTargetHTMLTableHeaderCellElement :: EventTarget H.HTMLTableHeaderCellElement where 244 | toEventTarget = U.unsafeCoerce 245 | 246 | instance eventTargetHTMLFormElement :: EventTarget H.HTMLFormElement where 247 | toEventTarget = U.unsafeCoerce 248 | 249 | instance eventTargetHTMLLabelElement :: EventTarget H.HTMLLabelElement where 250 | toEventTarget = U.unsafeCoerce 251 | 252 | instance eventTargetHTMLInputElement :: EventTarget H.HTMLInputElement where 253 | toEventTarget = U.unsafeCoerce 254 | 255 | instance eventTargetHTMLButtonElement :: EventTarget H.HTMLButtonElement where 256 | toEventTarget = U.unsafeCoerce 257 | 258 | instance eventTargetHTMLSelectElement :: EventTarget H.HTMLSelectElement where 259 | toEventTarget = U.unsafeCoerce 260 | 261 | instance eventTargetHTMLDataListElement :: EventTarget H.HTMLDataListElement where 262 | toEventTarget = U.unsafeCoerce 263 | 264 | instance eventTargetHTMLOptGroupElement :: EventTarget H.HTMLOptGroupElement where 265 | toEventTarget = U.unsafeCoerce 266 | 267 | instance eventTargetHTMLOptionElement :: EventTarget H.HTMLOptionElement where 268 | toEventTarget = U.unsafeCoerce 269 | 270 | instance eventTargetHTMLTextAreaElement :: EventTarget H.HTMLTextAreaElement where 271 | toEventTarget = U.unsafeCoerce 272 | 273 | instance eventTargetHTMLKeygenElement :: EventTarget H.HTMLKeygenElement where 274 | toEventTarget = U.unsafeCoerce 275 | 276 | instance eventTargetHTMLOutputElement :: EventTarget H.HTMLOutputElement where 277 | toEventTarget = U.unsafeCoerce 278 | 279 | instance eventTargetHTMLProgressElement :: EventTarget H.HTMLProgressElement where 280 | toEventTarget = U.unsafeCoerce 281 | 282 | instance eventTargetHTMLMeterElement :: EventTarget H.HTMLMeterElement where 283 | toEventTarget = U.unsafeCoerce 284 | 285 | instance eventTargetHTMLFieldSetElement :: EventTarget H.HTMLFieldSetElement where 286 | toEventTarget = U.unsafeCoerce 287 | 288 | instance eventTargetHTMLLegendElement :: EventTarget H.HTMLLegendElement where 289 | toEventTarget = U.unsafeCoerce 290 | 291 | instance eventTargetHTMLScriptElement :: EventTarget H.HTMLScriptElement where 292 | toEventTarget = U.unsafeCoerce 293 | 294 | instance eventTargetHTMLTemplateElement :: EventTarget H.HTMLTemplateElement where 295 | toEventTarget = U.unsafeCoerce 296 | 297 | instance eventTargetHTMLCanvasElement :: EventTarget H.HTMLCanvasElement where 298 | toEventTarget = U.unsafeCoerce 299 | -------------------------------------------------------------------------------- /src/DOM/Classy/ParentNode.purs: -------------------------------------------------------------------------------- 1 | module DOM.Classy.ParentNode where 2 | 3 | import Prelude 4 | 5 | import Control.Monad.Eff (Eff) 6 | 7 | import Data.Maybe (Maybe) 8 | 9 | import DOM (DOM) 10 | import DOM.Classy.Util (fromAny) 11 | import DOM.HTML.Types as H 12 | import DOM.Node.ParentNode as PN 13 | import DOM.Node.Types as N 14 | 15 | import Unsafe.Coerce as U 16 | 17 | -- | A class for subtypes of `ParentNode`. 18 | class IsParentNode n where 19 | toParentNode :: n -> N.ParentNode 20 | fromParentNode :: N.ParentNode -> Maybe n 21 | 22 | -- | The child elements for the node. 23 | children :: forall n eff. IsParentNode n => n -> Eff (dom :: DOM | eff) N.HTMLCollection 24 | children = PN.children <<< toParentNode 25 | 26 | -- | The first child that is an element, or null if no such element exists. 27 | firstElementChild :: forall n eff. IsParentNode n => n -> Eff (dom :: DOM | eff) (Maybe N.Element) 28 | firstElementChild = PN.firstElementChild <<< toParentNode 29 | 30 | -- | The last child that is an element, or null if no such element exists. 31 | lastElementChild :: forall n eff. IsParentNode n => n -> Eff (dom :: DOM | eff) (Maybe N.Element) 32 | lastElementChild = PN.lastElementChild <<< toParentNode 33 | 34 | -- | The number of child elements. 35 | childElementCount :: forall n eff. IsParentNode n => n -> Eff (dom :: DOM | eff) Int 36 | childElementCount = PN.childElementCount <<< toParentNode 37 | 38 | -- | Finds the first child that is an element that matches the selector(s), or 39 | -- | null if no such element exists. 40 | querySelector :: forall n eff. IsParentNode n => PN.QuerySelector -> n -> Eff (dom :: DOM | eff) (Maybe N.Element) 41 | querySelector selector = PN.querySelector selector <<< toParentNode 42 | 43 | -- | Finds all the child elements that matches the selector(s). 44 | querySelectorAll :: forall n eff. IsParentNode n => PN.QuerySelector -> n -> Eff (dom :: DOM | eff) N.NodeList 45 | querySelectorAll selector = PN.querySelectorAll selector <<< toParentNode 46 | 47 | instance isParentNodeDocument :: IsParentNode N.Document where 48 | toParentNode = U.unsafeCoerce 49 | fromParentNode = fromAny N.readDocument 50 | 51 | instance isParentNodeElement :: IsParentNode N.Element where 52 | toParentNode = U.unsafeCoerce 53 | fromParentNode = fromAny N.readElement 54 | 55 | instance isParentNodeHTMLDocument :: IsParentNode H.HTMLDocument where 56 | toParentNode = U.unsafeCoerce 57 | fromParentNode = fromAny H.readHTMLDocument 58 | 59 | instance isParentNodeHTMLElement :: IsParentNode H.HTMLElement where 60 | toParentNode = U.unsafeCoerce 61 | fromParentNode = fromAny H.readHTMLElement 62 | 63 | instance isParentNodeHTMLHtmlElement :: IsParentNode H.HTMLHtmlElement where 64 | toParentNode = U.unsafeCoerce 65 | fromParentNode = fromAny H.readHTMLHtmlElement 66 | 67 | instance isParentNodeHTMLHeadElement :: IsParentNode H.HTMLHeadElement where 68 | toParentNode = U.unsafeCoerce 69 | fromParentNode = fromAny H.readHTMLHeadElement 70 | 71 | instance isParentNodeHTMLTitleElement :: IsParentNode H.HTMLTitleElement where 72 | toParentNode = U.unsafeCoerce 73 | fromParentNode = fromAny H.readHTMLTitleElement 74 | 75 | instance isParentNodeHTMLBaseElement :: IsParentNode H.HTMLBaseElement where 76 | toParentNode = U.unsafeCoerce 77 | fromParentNode = fromAny H.readHTMLBaseElement 78 | 79 | instance isParentNodeHTMLLinkElement :: IsParentNode H.HTMLLinkElement where 80 | toParentNode = U.unsafeCoerce 81 | fromParentNode = fromAny H.readHTMLLinkElement 82 | 83 | instance isParentNodeHTMLMetaElement :: IsParentNode H.HTMLMetaElement where 84 | toParentNode = U.unsafeCoerce 85 | fromParentNode = fromAny H.readHTMLMetaElement 86 | 87 | instance isParentNodeHTMLStyleElement :: IsParentNode H.HTMLStyleElement where 88 | toParentNode = U.unsafeCoerce 89 | fromParentNode = fromAny H.readHTMLStyleElement 90 | 91 | instance isParentNodeHTMLBodyElement :: IsParentNode H.HTMLBodyElement where 92 | toParentNode = U.unsafeCoerce 93 | fromParentNode = fromAny H.readHTMLBodyElement 94 | 95 | instance isParentNodeHTMLHeadingElement :: IsParentNode H.HTMLHeadingElement where 96 | toParentNode = U.unsafeCoerce 97 | fromParentNode = fromAny H.readHTMLHeadingElement 98 | 99 | instance isParentNodeHTMLParagraphElement :: IsParentNode H.HTMLParagraphElement where 100 | toParentNode = U.unsafeCoerce 101 | fromParentNode = fromAny H.readHTMLParagraphElement 102 | 103 | instance isParentNodeHTMLHRElement :: IsParentNode H.HTMLHRElement where 104 | toParentNode = U.unsafeCoerce 105 | fromParentNode = fromAny H.readHTMLHRElement 106 | 107 | instance isParentNodeHTMLPreElement :: IsParentNode H.HTMLPreElement where 108 | toParentNode = U.unsafeCoerce 109 | fromParentNode = fromAny H.readHTMLPreElement 110 | 111 | instance isParentNodeHTMLQuoteElement :: IsParentNode H.HTMLQuoteElement where 112 | toParentNode = U.unsafeCoerce 113 | fromParentNode = fromAny H.readHTMLQuoteElement 114 | 115 | instance isParentNodeHTMLOListElement :: IsParentNode H.HTMLOListElement where 116 | toParentNode = U.unsafeCoerce 117 | fromParentNode = fromAny H.readHTMLOListElement 118 | 119 | instance isParentNodeHTMLUListElement :: IsParentNode H.HTMLUListElement where 120 | toParentNode = U.unsafeCoerce 121 | fromParentNode = fromAny H.readHTMLUListElement 122 | 123 | instance isParentNodeHTMLLIElement :: IsParentNode H.HTMLLIElement where 124 | toParentNode = U.unsafeCoerce 125 | fromParentNode = fromAny H.readHTMLLIElement 126 | 127 | instance isParentNodeHTMLDListElement :: IsParentNode H.HTMLDListElement where 128 | toParentNode = U.unsafeCoerce 129 | fromParentNode = fromAny H.readHTMLDListElement 130 | 131 | instance isParentNodeHTMLDivElement :: IsParentNode H.HTMLDivElement where 132 | toParentNode = U.unsafeCoerce 133 | fromParentNode = fromAny H.readHTMLDivElement 134 | 135 | instance isParentNodeHTMLAnchorElement :: IsParentNode H.HTMLAnchorElement where 136 | toParentNode = U.unsafeCoerce 137 | fromParentNode = fromAny H.readHTMLAnchorElement 138 | 139 | instance isParentNodeHTMLDataElement :: IsParentNode H.HTMLDataElement where 140 | toParentNode = U.unsafeCoerce 141 | fromParentNode = fromAny H.readHTMLDataElement 142 | 143 | instance isParentNodeHTMLTimeElement :: IsParentNode H.HTMLTimeElement where 144 | toParentNode = U.unsafeCoerce 145 | fromParentNode = fromAny H.readHTMLTimeElement 146 | 147 | instance isParentNodeHTMLSpanElement :: IsParentNode H.HTMLSpanElement where 148 | toParentNode = U.unsafeCoerce 149 | fromParentNode = fromAny H.readHTMLSpanElement 150 | 151 | instance isParentNodeHTMLBRElement :: IsParentNode H.HTMLBRElement where 152 | toParentNode = U.unsafeCoerce 153 | fromParentNode = fromAny H.readHTMLBRElement 154 | 155 | instance isParentNodeHTMLModElement :: IsParentNode H.HTMLModElement where 156 | toParentNode = U.unsafeCoerce 157 | fromParentNode = fromAny H.readHTMLModElement 158 | 159 | instance isParentNodeHTMLImageElement :: IsParentNode H.HTMLImageElement where 160 | toParentNode = U.unsafeCoerce 161 | fromParentNode = fromAny H.readHTMLImageElement 162 | 163 | instance isParentNodeHTMLIFrameElement :: IsParentNode H.HTMLIFrameElement where 164 | toParentNode = U.unsafeCoerce 165 | fromParentNode = fromAny H.readHTMLIFrameElement 166 | 167 | instance isParentNodeHTMLEmbedElement :: IsParentNode H.HTMLEmbedElement where 168 | toParentNode = U.unsafeCoerce 169 | fromParentNode = fromAny H.readHTMLEmbedElement 170 | 171 | instance isParentNodeHTMLObjectElement :: IsParentNode H.HTMLObjectElement where 172 | toParentNode = U.unsafeCoerce 173 | fromParentNode = fromAny H.readHTMLObjectElement 174 | 175 | instance isParentNodeHTMLParamElement :: IsParentNode H.HTMLParamElement where 176 | toParentNode = U.unsafeCoerce 177 | fromParentNode = fromAny H.readHTMLParamElement 178 | 179 | instance isParentNodeHTMLMediaElement :: IsParentNode H.HTMLMediaElement where 180 | toParentNode = U.unsafeCoerce 181 | fromParentNode = fromAny H.readHTMLMediaElement 182 | 183 | instance isParentNodeHTMLAudioElement :: IsParentNode H.HTMLAudioElement where 184 | toParentNode = U.unsafeCoerce 185 | fromParentNode = fromAny H.readHTMLAudioElement 186 | 187 | instance isParentNodeHTMLVideoElement :: IsParentNode H.HTMLVideoElement where 188 | toParentNode = U.unsafeCoerce 189 | fromParentNode = fromAny H.readHTMLVideoElement 190 | 191 | instance isParentNodeHTMLSourceElement :: IsParentNode H.HTMLSourceElement where 192 | toParentNode = U.unsafeCoerce 193 | fromParentNode = fromAny H.readHTMLSourceElement 194 | 195 | instance isParentNodeHTMLTrackElement :: IsParentNode H.HTMLTrackElement where 196 | toParentNode = U.unsafeCoerce 197 | fromParentNode = fromAny H.readHTMLTrackElement 198 | 199 | instance isParentNodeHTMLMapElement :: IsParentNode H.HTMLMapElement where 200 | toParentNode = U.unsafeCoerce 201 | fromParentNode = fromAny H.readHTMLMapElement 202 | 203 | instance isParentNodeHTMLAreaElement :: IsParentNode H.HTMLAreaElement where 204 | toParentNode = U.unsafeCoerce 205 | fromParentNode = fromAny H.readHTMLAreaElement 206 | 207 | instance isParentNodeHTMLTableElement :: IsParentNode H.HTMLTableElement where 208 | toParentNode = U.unsafeCoerce 209 | fromParentNode = fromAny H.readHTMLTableElement 210 | 211 | instance isParentNodeHTMLTableCaptionElement :: IsParentNode H.HTMLTableCaptionElement where 212 | toParentNode = U.unsafeCoerce 213 | fromParentNode = fromAny H.readHTMLTableCaptionElement 214 | 215 | instance isParentNodeHTMLTableColElement :: IsParentNode H.HTMLTableColElement where 216 | toParentNode = U.unsafeCoerce 217 | fromParentNode = fromAny H.readHTMLTableColElement 218 | 219 | instance isParentNodeHTMLTableSectionElement :: IsParentNode H.HTMLTableSectionElement where 220 | toParentNode = U.unsafeCoerce 221 | fromParentNode = fromAny H.readHTMLTableSectionElement 222 | 223 | instance isParentNodeHTMLTableRowElement :: IsParentNode H.HTMLTableRowElement where 224 | toParentNode = U.unsafeCoerce 225 | fromParentNode = fromAny H.readHTMLTableRowElement 226 | 227 | instance isParentNodeHTMLTableCellElement :: IsParentNode H.HTMLTableCellElement where 228 | toParentNode = U.unsafeCoerce 229 | fromParentNode = fromAny H.readHTMLTableCellElement 230 | 231 | instance isParentNodeHTMLTableDataCellElement :: IsParentNode H.HTMLTableDataCellElement where 232 | toParentNode = U.unsafeCoerce 233 | fromParentNode = fromAny H.readHTMLTableDataCellElement 234 | 235 | instance isParentNodeHTMLTableHeaderCellElement :: IsParentNode H.HTMLTableHeaderCellElement where 236 | toParentNode = U.unsafeCoerce 237 | fromParentNode = fromAny H.readHTMLTableHeaderCellElement 238 | 239 | instance isParentNodeHTMLFormElement :: IsParentNode H.HTMLFormElement where 240 | toParentNode = U.unsafeCoerce 241 | fromParentNode = fromAny H.readHTMLFormElement 242 | 243 | instance isParentNodeHTMLLabelElement :: IsParentNode H.HTMLLabelElement where 244 | toParentNode = U.unsafeCoerce 245 | fromParentNode = fromAny H.readHTMLLabelElement 246 | 247 | instance isParentNodeHTMLInputElement :: IsParentNode H.HTMLInputElement where 248 | toParentNode = U.unsafeCoerce 249 | fromParentNode = fromAny H.readHTMLInputElement 250 | 251 | instance isParentNodeHTMLButtonElement :: IsParentNode H.HTMLButtonElement where 252 | toParentNode = U.unsafeCoerce 253 | fromParentNode = fromAny H.readHTMLButtonElement 254 | 255 | instance isParentNodeHTMLSelectElement :: IsParentNode H.HTMLSelectElement where 256 | toParentNode = U.unsafeCoerce 257 | fromParentNode = fromAny H.readHTMLSelectElement 258 | 259 | instance isParentNodeHTMLDataListElement :: IsParentNode H.HTMLDataListElement where 260 | toParentNode = U.unsafeCoerce 261 | fromParentNode = fromAny H.readHTMLDataListElement 262 | 263 | instance isParentNodeHTMLOptGroupElement :: IsParentNode H.HTMLOptGroupElement where 264 | toParentNode = U.unsafeCoerce 265 | fromParentNode = fromAny H.readHTMLOptGroupElement 266 | 267 | instance isParentNodeHTMLOptionElement :: IsParentNode H.HTMLOptionElement where 268 | toParentNode = U.unsafeCoerce 269 | fromParentNode = fromAny H.readHTMLOptionElement 270 | 271 | instance isParentNodeHTMLTextAreaElement :: IsParentNode H.HTMLTextAreaElement where 272 | toParentNode = U.unsafeCoerce 273 | fromParentNode = fromAny H.readHTMLTextAreaElement 274 | 275 | instance isParentNodeHTMLKeygenElement :: IsParentNode H.HTMLKeygenElement where 276 | toParentNode = U.unsafeCoerce 277 | fromParentNode = fromAny H.readHTMLKeygenElement 278 | 279 | instance isParentNodeHTMLOutputElement :: IsParentNode H.HTMLOutputElement where 280 | toParentNode = U.unsafeCoerce 281 | fromParentNode = fromAny H.readHTMLOutputElement 282 | 283 | instance isParentNodeHTMLProgressElement :: IsParentNode H.HTMLProgressElement where 284 | toParentNode = U.unsafeCoerce 285 | fromParentNode = fromAny H.readHTMLProgressElement 286 | 287 | instance isParentNodeHTMLMeterElement :: IsParentNode H.HTMLMeterElement where 288 | toParentNode = U.unsafeCoerce 289 | fromParentNode = fromAny H.readHTMLMeterElement 290 | 291 | instance isParentNodeHTMLFieldSetElement :: IsParentNode H.HTMLFieldSetElement where 292 | toParentNode = U.unsafeCoerce 293 | fromParentNode = fromAny H.readHTMLFieldSetElement 294 | 295 | instance isParentNodeHTMLLegendElement :: IsParentNode H.HTMLLegendElement where 296 | toParentNode = U.unsafeCoerce 297 | fromParentNode = fromAny H.readHTMLLegendElement 298 | 299 | instance isParentNodeHTMLScriptElement :: IsParentNode H.HTMLScriptElement where 300 | toParentNode = U.unsafeCoerce 301 | fromParentNode = fromAny H.readHTMLScriptElement 302 | 303 | instance isParentNodeHTMLTemplateElement :: IsParentNode H.HTMLTemplateElement where 304 | toParentNode = U.unsafeCoerce 305 | fromParentNode = fromAny H.readHTMLTemplateElement 306 | 307 | instance isParentNodeHTMLCanvasElement :: IsParentNode H.HTMLCanvasElement where 308 | toParentNode = U.unsafeCoerce 309 | fromParentNode = fromAny H.readHTMLCanvasElement 310 | -------------------------------------------------------------------------------- /src/DOM/Classy/Element.purs: -------------------------------------------------------------------------------- 1 | module DOM.Classy.Element 2 | ( module DOM.Classy.Element 3 | , module Exports 4 | ) where 5 | 6 | import Prelude hiding (id) 7 | import Prelude as P 8 | 9 | import Control.Monad.Eff (Eff) 10 | import Data.Maybe (Maybe(..)) 11 | 12 | import DOM.Classy.Node (class IsNode) 13 | import DOM.Classy.Util (fromAny) 14 | import DOM.HTML.Types as H 15 | 16 | import DOM (DOM) 17 | import DOM.Node.Types as N 18 | import DOM.Node.Element as NE 19 | 20 | import Unsafe.Coerce as U 21 | 22 | import DOM.Classy.Node (appendChild, baseURI, childNodes, compareDocumentPositionBits, contains, firstChild, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, lastChild, lookupNamespaceURI, lookupPrefix, nextSibling, nodeName, nodeType, nodeTypeIndex, nodeValue, normalize, ownerDocument, parentElement, parentNode, previousSibling, removeChild, replaceChild, setNodeValue, setTextContent, textContent) as Exports 23 | 24 | -- | A class for subtypes of `Element`. 25 | class IsNode e <= IsElement e where 26 | toElement :: e -> N.Element 27 | fromElement :: N.Element -> Maybe e 28 | 29 | namespaceURI :: forall el. IsElement el => el -> Maybe String 30 | namespaceURI = NE.namespaceURI <<< toElement 31 | 32 | prefix :: forall el. IsElement el => el -> Maybe String 33 | prefix = NE.prefix <<< toElement 34 | 35 | localName :: forall el. IsElement el => el -> String 36 | localName = NE.localName <<< toElement 37 | 38 | tagName :: forall el. IsElement el => el -> String 39 | tagName = NE.tagName <<< toElement 40 | 41 | id :: forall eff el. IsElement el => el -> Eff (dom :: DOM | eff) N.ElementId 42 | id = NE.id <<< toElement 43 | 44 | setId :: forall eff el. IsElement el => N.ElementId -> el -> Eff (dom :: DOM | eff) Unit 45 | setId ei = NE.setId ei <<< toElement 46 | 47 | className :: forall eff el. IsElement el => el -> Eff (dom :: DOM | eff) String 48 | className = NE.className <<< toElement 49 | 50 | setClassName :: forall eff el. IsElement el => String -> el -> Eff (dom :: DOM | eff) Unit 51 | setClassName x = NE.setClassName x <<< toElement 52 | 53 | getElementsByTagName :: forall eff el. IsElement el => String -> el -> Eff (dom :: DOM | eff) N.HTMLCollection 54 | getElementsByTagName x = NE.getElementsByTagName x <<< toElement 55 | 56 | getElementsByTagNameNS :: forall eff el. IsElement el => Maybe String -> String -> el -> Eff (dom :: DOM | eff) N.HTMLCollection 57 | getElementsByTagNameNS x y = NE.getElementsByTagNameNS x y <<< toElement 58 | 59 | getElementsByClassName :: forall eff el. IsElement el => String -> el -> Eff (dom :: DOM | eff) N.HTMLCollection 60 | getElementsByClassName x = NE.getElementsByClassName x <<< toElement 61 | 62 | setAttribute :: forall eff el. IsElement el => String -> String -> el -> Eff (dom :: DOM | eff) Unit 63 | setAttribute x y = NE.setAttribute x y <<< toElement 64 | 65 | getAttribute :: forall eff el. IsElement el => String -> el -> Eff (dom :: DOM | eff) (Maybe String) 66 | getAttribute x = NE.getAttribute x <<< toElement 67 | 68 | removeAttribute :: forall eff el. IsElement el => String -> el -> Eff (dom :: DOM | eff) Unit 69 | removeAttribute x = NE.removeAttribute x <<< toElement 70 | 71 | scrollTop :: forall eff el. IsElement el => el -> Eff (dom :: DOM | eff) Number 72 | scrollTop = NE.scrollTop <<< toElement 73 | 74 | setScrollTop :: forall el eff. IsElement el => Number -> el -> Eff (dom :: DOM | eff) Unit 75 | setScrollTop st = NE.setScrollTop st <<< toElement 76 | 77 | scrollLeft :: forall eff el. IsElement el => el -> Eff (dom :: DOM | eff) Number 78 | scrollLeft = NE.scrollLeft <<< toElement 79 | 80 | setScrollLeft :: forall el eff. IsElement el => Number -> el -> Eff (dom :: DOM | eff) Unit 81 | setScrollLeft sl = NE.setScrollLeft sl <<< toElement 82 | 83 | scrollWidth :: forall eff el. IsElement el => el -> Eff (dom :: DOM | eff) Number 84 | scrollWidth = NE.scrollWidth <<< toElement 85 | 86 | scrollHeight :: forall eff el. IsElement el => el -> Eff (dom :: DOM | eff) Number 87 | scrollHeight = NE.scrollHeight <<< toElement 88 | 89 | clientTop :: forall eff el. IsElement el => el -> Eff (dom :: DOM | eff) Number 90 | clientTop = NE.clientTop <<< toElement 91 | 92 | clientLeft :: forall eff el. IsElement el => el -> Eff (dom :: DOM | eff) Number 93 | clientLeft = NE.clientLeft <<< toElement 94 | 95 | clientWidth :: forall eff el. IsElement el => el -> Eff (dom :: DOM | eff) Number 96 | clientWidth = NE.clientWidth <<< toElement 97 | 98 | clientHeight :: forall eff el. IsElement el => el -> Eff (dom :: DOM | eff) Number 99 | clientHeight = NE.clientHeight <<< toElement 100 | 101 | instance isElementElement :: IsElement N.Element where 102 | toElement = P.id 103 | fromElement = Just 104 | 105 | instance isElementHTMLElement :: IsElement H.HTMLElement where 106 | toElement = U.unsafeCoerce 107 | fromElement = fromAny H.readHTMLElement 108 | 109 | instance isElementHTMLHtmlElement :: IsElement H.HTMLHtmlElement where 110 | toElement = U.unsafeCoerce 111 | fromElement = fromAny H.readHTMLHtmlElement 112 | 113 | instance isElementHTMLHeadElement :: IsElement H.HTMLHeadElement where 114 | toElement = U.unsafeCoerce 115 | fromElement = fromAny H.readHTMLHeadElement 116 | 117 | instance isElementHTMLTitleElement :: IsElement H.HTMLTitleElement where 118 | toElement = U.unsafeCoerce 119 | fromElement = fromAny H.readHTMLTitleElement 120 | 121 | instance isElementHTMLBaseElement :: IsElement H.HTMLBaseElement where 122 | toElement = U.unsafeCoerce 123 | fromElement = fromAny H.readHTMLBaseElement 124 | 125 | instance isElementHTMLLinkElement :: IsElement H.HTMLLinkElement where 126 | toElement = U.unsafeCoerce 127 | fromElement = fromAny H.readHTMLLinkElement 128 | 129 | instance isElementHTMLMetaElement :: IsElement H.HTMLMetaElement where 130 | toElement = U.unsafeCoerce 131 | fromElement = fromAny H.readHTMLMetaElement 132 | 133 | instance isElementHTMLStyleElement :: IsElement H.HTMLStyleElement where 134 | toElement = U.unsafeCoerce 135 | fromElement = fromAny H.readHTMLStyleElement 136 | 137 | instance isElementHTMLBodyElement :: IsElement H.HTMLBodyElement where 138 | toElement = U.unsafeCoerce 139 | fromElement = fromAny H.readHTMLBodyElement 140 | 141 | instance isElementHTMLHeadingElement :: IsElement H.HTMLHeadingElement where 142 | toElement = U.unsafeCoerce 143 | fromElement = fromAny H.readHTMLHeadingElement 144 | 145 | instance isElementHTMLParagraphElement :: IsElement H.HTMLParagraphElement where 146 | toElement = U.unsafeCoerce 147 | fromElement = fromAny H.readHTMLParagraphElement 148 | 149 | instance isElementHTMLHRElement :: IsElement H.HTMLHRElement where 150 | toElement = U.unsafeCoerce 151 | fromElement = fromAny H.readHTMLHRElement 152 | 153 | instance isElementHTMLPreElement :: IsElement H.HTMLPreElement where 154 | toElement = U.unsafeCoerce 155 | fromElement = fromAny H.readHTMLPreElement 156 | 157 | instance isElementHTMLQuoteElement :: IsElement H.HTMLQuoteElement where 158 | toElement = U.unsafeCoerce 159 | fromElement = fromAny H.readHTMLQuoteElement 160 | 161 | instance isElementHTMLOListElement :: IsElement H.HTMLOListElement where 162 | toElement = U.unsafeCoerce 163 | fromElement = fromAny H.readHTMLOListElement 164 | 165 | instance isElementHTMLUListElement :: IsElement H.HTMLUListElement where 166 | toElement = U.unsafeCoerce 167 | fromElement = fromAny H.readHTMLUListElement 168 | 169 | instance isElementHTMLLIElement :: IsElement H.HTMLLIElement where 170 | toElement = U.unsafeCoerce 171 | fromElement = fromAny H.readHTMLLIElement 172 | 173 | instance isElementHTMLDListElement :: IsElement H.HTMLDListElement where 174 | toElement = U.unsafeCoerce 175 | fromElement = fromAny H.readHTMLDListElement 176 | 177 | instance isElementHTMLDivElement :: IsElement H.HTMLDivElement where 178 | toElement = U.unsafeCoerce 179 | fromElement = fromAny H.readHTMLDivElement 180 | 181 | instance isElementHTMLAnchorElement :: IsElement H.HTMLAnchorElement where 182 | toElement = U.unsafeCoerce 183 | fromElement = fromAny H.readHTMLAnchorElement 184 | 185 | instance isElementHTMLDataElement :: IsElement H.HTMLDataElement where 186 | toElement = U.unsafeCoerce 187 | fromElement = fromAny H.readHTMLDataElement 188 | 189 | instance isElementHTMLTimeElement :: IsElement H.HTMLTimeElement where 190 | toElement = U.unsafeCoerce 191 | fromElement = fromAny H.readHTMLTimeElement 192 | 193 | instance isElementHTMLSpanElement :: IsElement H.HTMLSpanElement where 194 | toElement = U.unsafeCoerce 195 | fromElement = fromAny H.readHTMLSpanElement 196 | 197 | instance isElementHTMLBRElement :: IsElement H.HTMLBRElement where 198 | toElement = U.unsafeCoerce 199 | fromElement = fromAny H.readHTMLBRElement 200 | 201 | instance isElementHTMLModElement :: IsElement H.HTMLModElement where 202 | toElement = U.unsafeCoerce 203 | fromElement = fromAny H.readHTMLModElement 204 | 205 | instance isElementHTMLImageElement :: IsElement H.HTMLImageElement where 206 | toElement = U.unsafeCoerce 207 | fromElement = fromAny H.readHTMLImageElement 208 | 209 | instance isElementHTMLIFrameElement :: IsElement H.HTMLIFrameElement where 210 | toElement = U.unsafeCoerce 211 | fromElement = fromAny H.readHTMLIFrameElement 212 | 213 | instance isElementHTMLEmbedElement :: IsElement H.HTMLEmbedElement where 214 | toElement = U.unsafeCoerce 215 | fromElement = fromAny H.readHTMLEmbedElement 216 | 217 | instance isElementHTMLObjectElement :: IsElement H.HTMLObjectElement where 218 | toElement = U.unsafeCoerce 219 | fromElement = fromAny H.readHTMLObjectElement 220 | 221 | instance isElementHTMLParamElement :: IsElement H.HTMLParamElement where 222 | toElement = U.unsafeCoerce 223 | fromElement = fromAny H.readHTMLParamElement 224 | 225 | instance isElementHTMLMediaElement :: IsElement H.HTMLMediaElement where 226 | toElement = U.unsafeCoerce 227 | fromElement = fromAny H.readHTMLMediaElement 228 | 229 | instance isElementHTMLAudioElement :: IsElement H.HTMLAudioElement where 230 | toElement = U.unsafeCoerce 231 | fromElement = fromAny H.readHTMLAudioElement 232 | 233 | instance isElementHTMLVideoElement :: IsElement H.HTMLVideoElement where 234 | toElement = U.unsafeCoerce 235 | fromElement = fromAny H.readHTMLVideoElement 236 | 237 | instance isElementHTMLSourceElement :: IsElement H.HTMLSourceElement where 238 | toElement = U.unsafeCoerce 239 | fromElement = fromAny H.readHTMLSourceElement 240 | 241 | instance isElementHTMLTrackElement :: IsElement H.HTMLTrackElement where 242 | toElement = U.unsafeCoerce 243 | fromElement = fromAny H.readHTMLTrackElement 244 | 245 | instance isElementHTMLMapElement :: IsElement H.HTMLMapElement where 246 | toElement = U.unsafeCoerce 247 | fromElement = fromAny H.readHTMLMapElement 248 | 249 | instance isElementHTMLAreaElement :: IsElement H.HTMLAreaElement where 250 | toElement = U.unsafeCoerce 251 | fromElement = fromAny H.readHTMLAreaElement 252 | 253 | instance isElementHTMLTableElement :: IsElement H.HTMLTableElement where 254 | toElement = U.unsafeCoerce 255 | fromElement = fromAny H.readHTMLTableElement 256 | 257 | instance isElementHTMLTableCaptionElement :: IsElement H.HTMLTableCaptionElement where 258 | toElement = U.unsafeCoerce 259 | fromElement = fromAny H.readHTMLTableCaptionElement 260 | 261 | instance isElementHTMLTableColElement :: IsElement H.HTMLTableColElement where 262 | toElement = U.unsafeCoerce 263 | fromElement = fromAny H.readHTMLTableColElement 264 | 265 | instance isElementHTMLTableSectionElement :: IsElement H.HTMLTableSectionElement where 266 | toElement = U.unsafeCoerce 267 | fromElement = fromAny H.readHTMLTableSectionElement 268 | 269 | instance isElementHTMLTableRowElement :: IsElement H.HTMLTableRowElement where 270 | toElement = U.unsafeCoerce 271 | fromElement = fromAny H.readHTMLTableRowElement 272 | 273 | instance isElementHTMLTableCellElement :: IsElement H.HTMLTableCellElement where 274 | toElement = U.unsafeCoerce 275 | fromElement = fromAny H.readHTMLTableCellElement 276 | 277 | instance isElementHTMLTableDataCellElement :: IsElement H.HTMLTableDataCellElement where 278 | toElement = U.unsafeCoerce 279 | fromElement = fromAny H.readHTMLTableDataCellElement 280 | 281 | instance isElementHTMLTableHeaderCellElement :: IsElement H.HTMLTableHeaderCellElement where 282 | toElement = U.unsafeCoerce 283 | fromElement = fromAny H.readHTMLTableHeaderCellElement 284 | 285 | instance isElementHTMLFormElement :: IsElement H.HTMLFormElement where 286 | toElement = U.unsafeCoerce 287 | fromElement = fromAny H.readHTMLFormElement 288 | 289 | instance isElementHTMLLabelElement :: IsElement H.HTMLLabelElement where 290 | toElement = U.unsafeCoerce 291 | fromElement = fromAny H.readHTMLLabelElement 292 | 293 | instance isElementHTMLInputElement :: IsElement H.HTMLInputElement where 294 | toElement = U.unsafeCoerce 295 | fromElement = fromAny H.readHTMLInputElement 296 | 297 | instance isElementHTMLButtonElement :: IsElement H.HTMLButtonElement where 298 | toElement = U.unsafeCoerce 299 | fromElement = fromAny H.readHTMLButtonElement 300 | 301 | instance isElementHTMLSelectElement :: IsElement H.HTMLSelectElement where 302 | toElement = U.unsafeCoerce 303 | fromElement = fromAny H.readHTMLSelectElement 304 | 305 | instance isElementHTMLDataListElement :: IsElement H.HTMLDataListElement where 306 | toElement = U.unsafeCoerce 307 | fromElement = fromAny H.readHTMLDataListElement 308 | 309 | instance isElementHTMLOptGroupElement :: IsElement H.HTMLOptGroupElement where 310 | toElement = U.unsafeCoerce 311 | fromElement = fromAny H.readHTMLOptGroupElement 312 | 313 | instance isElementHTMLOptionElement :: IsElement H.HTMLOptionElement where 314 | toElement = U.unsafeCoerce 315 | fromElement = fromAny H.readHTMLOptionElement 316 | 317 | instance isElementHTMLTextAreaElement :: IsElement H.HTMLTextAreaElement where 318 | toElement = U.unsafeCoerce 319 | fromElement = fromAny H.readHTMLTextAreaElement 320 | 321 | instance isElementHTMLKeygenElement :: IsElement H.HTMLKeygenElement where 322 | toElement = U.unsafeCoerce 323 | fromElement = fromAny H.readHTMLKeygenElement 324 | 325 | instance isElementHTMLOutputElement :: IsElement H.HTMLOutputElement where 326 | toElement = U.unsafeCoerce 327 | fromElement = fromAny H.readHTMLOutputElement 328 | 329 | instance isElementHTMLProgressElement :: IsElement H.HTMLProgressElement where 330 | toElement = U.unsafeCoerce 331 | fromElement = fromAny H.readHTMLProgressElement 332 | 333 | instance isElementHTMLMeterElement :: IsElement H.HTMLMeterElement where 334 | toElement = U.unsafeCoerce 335 | fromElement = fromAny H.readHTMLMeterElement 336 | 337 | instance isElementHTMLFieldSetElement :: IsElement H.HTMLFieldSetElement where 338 | toElement = U.unsafeCoerce 339 | fromElement = fromAny H.readHTMLFieldSetElement 340 | 341 | instance isElementHTMLLegendElement :: IsElement H.HTMLLegendElement where 342 | toElement = U.unsafeCoerce 343 | fromElement = fromAny H.readHTMLLegendElement 344 | 345 | instance isElementHTMLScriptElement :: IsElement H.HTMLScriptElement where 346 | toElement = U.unsafeCoerce 347 | fromElement = fromAny H.readHTMLScriptElement 348 | 349 | instance isElementHTMLTemplateElement :: IsElement H.HTMLTemplateElement where 350 | toElement = U.unsafeCoerce 351 | fromElement = fromAny H.readHTMLTemplateElement 352 | 353 | instance isElementHTMLCanvasElement :: IsElement H.HTMLCanvasElement where 354 | toElement = U.unsafeCoerce 355 | fromElement = fromAny H.readHTMLCanvasElement 356 | -------------------------------------------------------------------------------- /src/DOM/Classy/HTMLElement.purs: -------------------------------------------------------------------------------- 1 | module DOM.Classy.HTMLElement 2 | ( module DOM.Classy.HTMLElement 3 | , module Exports 4 | ) where 5 | 6 | import Prelude 7 | 8 | import Control.Monad.Eff (Eff) 9 | import Data.Maybe (Maybe(..)) 10 | 11 | import DOM (DOM) 12 | import DOM.Classy.Element (class IsElement) 13 | import DOM.Classy.Util (fromAny) 14 | import DOM.HTML.HTMLElement as HE 15 | import DOM.HTML.Types as H 16 | import DOM.Node.Types (Element) 17 | 18 | import Unsafe.Coerce as U 19 | 20 | import DOM.Classy.Element (appendChild, baseURI, childNodes, className, clientHeight, clientLeft, clientTop, clientWidth, compareDocumentPositionBits, contains, firstChild, getAttribute, getElementsByClassName, getElementsByTagName, getElementsByTagNameNS, hasChildNodes, id, insertBefore, isDefaultNamespace, isEqualNode, lastChild, localName, lookupNamespaceURI, lookupPrefix, namespaceURI, nextSibling, nodeName, nodeType, nodeTypeIndex, nodeValue, normalize, ownerDocument, parentElement, parentNode, prefix, previousSibling, removeAttribute, removeChild, replaceChild, scrollHeight, scrollLeft, scrollTop, scrollWidth, setAttribute, setClassName, setId, setNodeValue, setScrollLeft, setScrollTop, setTextContent, tagName, textContent) as Exports 21 | 22 | -- | A class for subtypes of `HTMLElement`. 23 | class IsElement e <= IsHTMLElement e where 24 | toHTMLElement :: e -> H.HTMLElement 25 | fromHTMLElement :: H.HTMLElement -> Maybe e 26 | 27 | title :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) String 28 | title = HE.title <<< toHTMLElement 29 | 30 | setTitle :: forall el eff. IsHTMLElement el => String -> el -> Eff (dom :: DOM | eff) Unit 31 | setTitle t = HE.setTitle t <<< toHTMLElement 32 | 33 | lang :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) String 34 | lang = HE.lang <<< toHTMLElement 35 | 36 | setLang :: forall el eff. IsHTMLElement el => String -> el -> Eff (dom :: DOM | eff) Unit 37 | setLang l = HE.setLang l <<< toHTMLElement 38 | 39 | dir :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) String 40 | dir = HE.dir <<< toHTMLElement 41 | 42 | setDir :: forall el eff. IsHTMLElement el => String -> el -> Eff (dom :: DOM | eff) Unit 43 | setDir d = HE.setDir d <<< toHTMLElement 44 | 45 | hidden :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Boolean 46 | hidden = HE.hidden <<< toHTMLElement 47 | 48 | setHidden :: forall el eff. IsHTMLElement el => Boolean -> el -> Eff (dom :: DOM | eff) Unit 49 | setHidden h = HE.setHidden h <<< toHTMLElement 50 | 51 | tabIndex :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Int 52 | tabIndex = HE.tabIndex <<< toHTMLElement 53 | 54 | setTabIndex :: forall el eff. IsHTMLElement el => Int -> el -> Eff (dom :: DOM | eff) Unit 55 | setTabIndex ti = HE.setTabIndex ti <<< toHTMLElement 56 | 57 | draggable :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Boolean 58 | draggable = HE.draggable <<< toHTMLElement 59 | 60 | setDraggable :: forall el eff. IsHTMLElement el => Boolean -> el -> Eff (dom :: DOM | eff) Unit 61 | setDraggable d = HE.setDraggable d <<< toHTMLElement 62 | 63 | contentEditable :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) String 64 | contentEditable = HE.contentEditable <<< toHTMLElement 65 | 66 | setContentEditable :: forall el eff. IsHTMLElement el => String -> el -> Eff (dom :: DOM | eff) Unit 67 | setContentEditable ce = HE.setContentEditable ce <<< toHTMLElement 68 | 69 | isContentEditable :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Boolean 70 | isContentEditable = HE.isContentEditable <<< toHTMLElement 71 | 72 | spellcheck :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Boolean 73 | spellcheck = HE.spellcheck <<< toHTMLElement 74 | 75 | setSpellcheck :: forall el eff. IsHTMLElement el => Boolean -> el -> Eff (dom :: DOM | eff) Unit 76 | setSpellcheck s = HE.setSpellcheck s <<< toHTMLElement 77 | 78 | click :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Unit 79 | click = HE.click <<< toHTMLElement 80 | 81 | focus :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Unit 82 | focus = HE.focus <<< toHTMLElement 83 | 84 | blur :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Unit 85 | blur = HE.blur <<< toHTMLElement 86 | 87 | getBoundingClientRect :: forall el eff . IsHTMLElement el => el -> Eff (dom :: DOM | eff) HE.DOMRect 88 | getBoundingClientRect = HE.getBoundingClientRect <<< toHTMLElement 89 | 90 | offsetParent :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) (Maybe Element) 91 | offsetParent = HE.offsetParent <<< toHTMLElement 92 | 93 | offsetTop :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Number 94 | offsetTop = HE.offsetTop <<< toHTMLElement 95 | 96 | offsetLeft :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Number 97 | offsetLeft = HE.offsetLeft <<< toHTMLElement 98 | 99 | offsetWidth :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Number 100 | offsetWidth = HE.offsetWidth <<< toHTMLElement 101 | 102 | offsetHeight :: forall el eff. IsHTMLElement el => el -> Eff (dom :: DOM | eff) Number 103 | offsetHeight = HE.offsetHeight <<< toHTMLElement 104 | 105 | instance isHTMLElementHTMLElement :: IsHTMLElement H.HTMLElement where 106 | toHTMLElement = id 107 | fromHTMLElement = Just 108 | 109 | instance isHTMLElementHTMLHtmlElement :: IsHTMLElement H.HTMLHtmlElement where 110 | toHTMLElement = U.unsafeCoerce 111 | fromHTMLElement = fromAny H.readHTMLHtmlElement 112 | 113 | instance isHTMLElementHTMLHeadElement :: IsHTMLElement H.HTMLHeadElement where 114 | toHTMLElement = U.unsafeCoerce 115 | fromHTMLElement = fromAny H.readHTMLHeadElement 116 | 117 | instance isHTMLElementHTMLTitleElement :: IsHTMLElement H.HTMLTitleElement where 118 | toHTMLElement = U.unsafeCoerce 119 | fromHTMLElement = fromAny H.readHTMLTitleElement 120 | 121 | instance isHTMLElementHTMLBaseElement :: IsHTMLElement H.HTMLBaseElement where 122 | toHTMLElement = U.unsafeCoerce 123 | fromHTMLElement = fromAny H.readHTMLBaseElement 124 | 125 | instance isHTMLElementHTMLLinkElement :: IsHTMLElement H.HTMLLinkElement where 126 | toHTMLElement = U.unsafeCoerce 127 | fromHTMLElement = fromAny H.readHTMLLinkElement 128 | 129 | instance isHTMLElementHTMLMetaElement :: IsHTMLElement H.HTMLMetaElement where 130 | toHTMLElement = U.unsafeCoerce 131 | fromHTMLElement = fromAny H.readHTMLMetaElement 132 | 133 | instance isHTMLElementHTMLStyleElement :: IsHTMLElement H.HTMLStyleElement where 134 | toHTMLElement = U.unsafeCoerce 135 | fromHTMLElement = fromAny H.readHTMLStyleElement 136 | 137 | instance isHTMLElementHTMLBodyElement :: IsHTMLElement H.HTMLBodyElement where 138 | toHTMLElement = U.unsafeCoerce 139 | fromHTMLElement = fromAny H.readHTMLBodyElement 140 | 141 | instance isHTMLElementHTMLHeadingElement :: IsHTMLElement H.HTMLHeadingElement where 142 | toHTMLElement = U.unsafeCoerce 143 | fromHTMLElement = fromAny H.readHTMLHeadingElement 144 | 145 | instance isHTMLElementHTMLParagraphElement :: IsHTMLElement H.HTMLParagraphElement where 146 | toHTMLElement = U.unsafeCoerce 147 | fromHTMLElement = fromAny H.readHTMLParagraphElement 148 | 149 | instance isHTMLElementHTMLHRElement :: IsHTMLElement H.HTMLHRElement where 150 | toHTMLElement = U.unsafeCoerce 151 | fromHTMLElement = fromAny H.readHTMLHRElement 152 | 153 | instance isHTMLElementHTMLPreElement :: IsHTMLElement H.HTMLPreElement where 154 | toHTMLElement = U.unsafeCoerce 155 | fromHTMLElement = fromAny H.readHTMLPreElement 156 | 157 | instance isHTMLElementHTMLQuoteElement :: IsHTMLElement H.HTMLQuoteElement where 158 | toHTMLElement = U.unsafeCoerce 159 | fromHTMLElement = fromAny H.readHTMLQuoteElement 160 | 161 | instance isHTMLElementHTMLOListElement :: IsHTMLElement H.HTMLOListElement where 162 | toHTMLElement = U.unsafeCoerce 163 | fromHTMLElement = fromAny H.readHTMLOListElement 164 | 165 | instance isHTMLElementHTMLUListElement :: IsHTMLElement H.HTMLUListElement where 166 | toHTMLElement = U.unsafeCoerce 167 | fromHTMLElement = fromAny H.readHTMLUListElement 168 | 169 | instance isHTMLElementHTMLLIElement :: IsHTMLElement H.HTMLLIElement where 170 | toHTMLElement = U.unsafeCoerce 171 | fromHTMLElement = fromAny H.readHTMLLIElement 172 | 173 | instance isHTMLElementHTMLDListElement :: IsHTMLElement H.HTMLDListElement where 174 | toHTMLElement = U.unsafeCoerce 175 | fromHTMLElement = fromAny H.readHTMLDListElement 176 | 177 | instance isHTMLElementHTMLDivElement :: IsHTMLElement H.HTMLDivElement where 178 | toHTMLElement = U.unsafeCoerce 179 | fromHTMLElement = fromAny H.readHTMLDivElement 180 | 181 | instance isHTMLElementHTMLAnchorElement :: IsHTMLElement H.HTMLAnchorElement where 182 | toHTMLElement = U.unsafeCoerce 183 | fromHTMLElement = fromAny H.readHTMLAnchorElement 184 | 185 | instance isHTMLElementHTMLDataElement :: IsHTMLElement H.HTMLDataElement where 186 | toHTMLElement = U.unsafeCoerce 187 | fromHTMLElement = fromAny H.readHTMLDataElement 188 | 189 | instance isHTMLElementHTMLTimeElement :: IsHTMLElement H.HTMLTimeElement where 190 | toHTMLElement = U.unsafeCoerce 191 | fromHTMLElement = fromAny H.readHTMLTimeElement 192 | 193 | instance isHTMLElementHTMLSpanElement :: IsHTMLElement H.HTMLSpanElement where 194 | toHTMLElement = U.unsafeCoerce 195 | fromHTMLElement = fromAny H.readHTMLSpanElement 196 | 197 | instance isHTMLElementHTMLBRElement :: IsHTMLElement H.HTMLBRElement where 198 | toHTMLElement = U.unsafeCoerce 199 | fromHTMLElement = fromAny H.readHTMLBRElement 200 | 201 | instance isHTMLElementHTMLModElement :: IsHTMLElement H.HTMLModElement where 202 | toHTMLElement = U.unsafeCoerce 203 | fromHTMLElement = fromAny H.readHTMLModElement 204 | 205 | instance isHTMLElementHTMLImageElement :: IsHTMLElement H.HTMLImageElement where 206 | toHTMLElement = U.unsafeCoerce 207 | fromHTMLElement = fromAny H.readHTMLImageElement 208 | 209 | instance isHTMLElementHTMLIFrameElement :: IsHTMLElement H.HTMLIFrameElement where 210 | toHTMLElement = U.unsafeCoerce 211 | fromHTMLElement = fromAny H.readHTMLIFrameElement 212 | 213 | instance isHTMLElementHTMLEmbedElement :: IsHTMLElement H.HTMLEmbedElement where 214 | toHTMLElement = U.unsafeCoerce 215 | fromHTMLElement = fromAny H.readHTMLEmbedElement 216 | 217 | instance isHTMLElementHTMLObjectElement :: IsHTMLElement H.HTMLObjectElement where 218 | toHTMLElement = U.unsafeCoerce 219 | fromHTMLElement = fromAny H.readHTMLObjectElement 220 | 221 | instance isHTMLElementHTMLParamElement :: IsHTMLElement H.HTMLParamElement where 222 | toHTMLElement = U.unsafeCoerce 223 | fromHTMLElement = fromAny H.readHTMLParamElement 224 | 225 | instance isHTMLElementHTMLMediaElement :: IsHTMLElement H.HTMLMediaElement where 226 | toHTMLElement = U.unsafeCoerce 227 | fromHTMLElement = fromAny H.readHTMLMediaElement 228 | 229 | instance isHTMLElementHTMLAudioElement :: IsHTMLElement H.HTMLAudioElement where 230 | toHTMLElement = U.unsafeCoerce 231 | fromHTMLElement = fromAny H.readHTMLAudioElement 232 | 233 | instance isHTMLElementHTMLVideoElement :: IsHTMLElement H.HTMLVideoElement where 234 | toHTMLElement = U.unsafeCoerce 235 | fromHTMLElement = fromAny H.readHTMLVideoElement 236 | 237 | instance isHTMLElementHTMLSourceElement :: IsHTMLElement H.HTMLSourceElement where 238 | toHTMLElement = U.unsafeCoerce 239 | fromHTMLElement = fromAny H.readHTMLSourceElement 240 | 241 | instance isHTMLElementHTMLTrackElement :: IsHTMLElement H.HTMLTrackElement where 242 | toHTMLElement = U.unsafeCoerce 243 | fromHTMLElement = fromAny H.readHTMLTrackElement 244 | 245 | instance isHTMLElementHTMLMapElement :: IsHTMLElement H.HTMLMapElement where 246 | toHTMLElement = U.unsafeCoerce 247 | fromHTMLElement = fromAny H.readHTMLMapElement 248 | 249 | instance isHTMLElementHTMLAreaElement :: IsHTMLElement H.HTMLAreaElement where 250 | toHTMLElement = U.unsafeCoerce 251 | fromHTMLElement = fromAny H.readHTMLAreaElement 252 | 253 | instance isHTMLElementHTMLTableElement :: IsHTMLElement H.HTMLTableElement where 254 | toHTMLElement = U.unsafeCoerce 255 | fromHTMLElement = fromAny H.readHTMLTableElement 256 | 257 | instance isHTMLElementHTMLTableCaptionElement :: IsHTMLElement H.HTMLTableCaptionElement where 258 | toHTMLElement = U.unsafeCoerce 259 | fromHTMLElement = fromAny H.readHTMLTableCaptionElement 260 | 261 | instance isHTMLElementHTMLTableColElement :: IsHTMLElement H.HTMLTableColElement where 262 | toHTMLElement = U.unsafeCoerce 263 | fromHTMLElement = fromAny H.readHTMLTableColElement 264 | 265 | instance isHTMLElementHTMLTableSectionElement :: IsHTMLElement H.HTMLTableSectionElement where 266 | toHTMLElement = U.unsafeCoerce 267 | fromHTMLElement = fromAny H.readHTMLTableSectionElement 268 | 269 | instance isHTMLElementHTMLTableRowElement :: IsHTMLElement H.HTMLTableRowElement where 270 | toHTMLElement = U.unsafeCoerce 271 | fromHTMLElement = fromAny H.readHTMLTableRowElement 272 | 273 | instance isHTMLElementHTMLTableCellElement :: IsHTMLElement H.HTMLTableCellElement where 274 | toHTMLElement = U.unsafeCoerce 275 | fromHTMLElement = fromAny H.readHTMLTableCellElement 276 | 277 | instance isHTMLElementHTMLTableDataCellElement :: IsHTMLElement H.HTMLTableDataCellElement where 278 | toHTMLElement = U.unsafeCoerce 279 | fromHTMLElement = fromAny H.readHTMLTableDataCellElement 280 | 281 | instance isHTMLElementHTMLTableHeaderCellElement :: IsHTMLElement H.HTMLTableHeaderCellElement where 282 | toHTMLElement = U.unsafeCoerce 283 | fromHTMLElement = fromAny H.readHTMLTableHeaderCellElement 284 | 285 | instance isHTMLElementHTMLFormElement :: IsHTMLElement H.HTMLFormElement where 286 | toHTMLElement = U.unsafeCoerce 287 | fromHTMLElement = fromAny H.readHTMLFormElement 288 | 289 | instance isHTMLElementHTMLLabelElement :: IsHTMLElement H.HTMLLabelElement where 290 | toHTMLElement = U.unsafeCoerce 291 | fromHTMLElement = fromAny H.readHTMLLabelElement 292 | 293 | instance isHTMLElementHTMLInputElement :: IsHTMLElement H.HTMLInputElement where 294 | toHTMLElement = U.unsafeCoerce 295 | fromHTMLElement = fromAny H.readHTMLInputElement 296 | 297 | instance isHTMLElementHTMLButtonElement :: IsHTMLElement H.HTMLButtonElement where 298 | toHTMLElement = U.unsafeCoerce 299 | fromHTMLElement = fromAny H.readHTMLButtonElement 300 | 301 | instance isHTMLElementHTMLSelectElement :: IsHTMLElement H.HTMLSelectElement where 302 | toHTMLElement = U.unsafeCoerce 303 | fromHTMLElement = fromAny H.readHTMLSelectElement 304 | 305 | instance isHTMLElementHTMLDataListElement :: IsHTMLElement H.HTMLDataListElement where 306 | toHTMLElement = U.unsafeCoerce 307 | fromHTMLElement = fromAny H.readHTMLDataListElement 308 | 309 | instance isHTMLElementHTMLOptGroupElement :: IsHTMLElement H.HTMLOptGroupElement where 310 | toHTMLElement = U.unsafeCoerce 311 | fromHTMLElement = fromAny H.readHTMLOptGroupElement 312 | 313 | instance isHTMLElementHTMLOptionElement :: IsHTMLElement H.HTMLOptionElement where 314 | toHTMLElement = U.unsafeCoerce 315 | fromHTMLElement = fromAny H.readHTMLOptionElement 316 | 317 | instance isHTMLElementHTMLTextAreaElement :: IsHTMLElement H.HTMLTextAreaElement where 318 | toHTMLElement = U.unsafeCoerce 319 | fromHTMLElement = fromAny H.readHTMLTextAreaElement 320 | 321 | instance isHTMLElementHTMLKeygenElement :: IsHTMLElement H.HTMLKeygenElement where 322 | toHTMLElement = U.unsafeCoerce 323 | fromHTMLElement = fromAny H.readHTMLKeygenElement 324 | 325 | instance isHTMLElementHTMLOutputElement :: IsHTMLElement H.HTMLOutputElement where 326 | toHTMLElement = U.unsafeCoerce 327 | fromHTMLElement = fromAny H.readHTMLOutputElement 328 | 329 | instance isHTMLElementHTMLProgressElement :: IsHTMLElement H.HTMLProgressElement where 330 | toHTMLElement = U.unsafeCoerce 331 | fromHTMLElement = fromAny H.readHTMLProgressElement 332 | 333 | instance isHTMLElementHTMLMeterElement :: IsHTMLElement H.HTMLMeterElement where 334 | toHTMLElement = U.unsafeCoerce 335 | fromHTMLElement = fromAny H.readHTMLMeterElement 336 | 337 | instance isHTMLElementHTMLFieldSetElement :: IsHTMLElement H.HTMLFieldSetElement where 338 | toHTMLElement = U.unsafeCoerce 339 | fromHTMLElement = fromAny H.readHTMLFieldSetElement 340 | 341 | instance isHTMLElementHTMLLegendElement :: IsHTMLElement H.HTMLLegendElement where 342 | toHTMLElement = U.unsafeCoerce 343 | fromHTMLElement = fromAny H.readHTMLLegendElement 344 | 345 | instance isHTMLElementHTMLScriptElement :: IsHTMLElement H.HTMLScriptElement where 346 | toHTMLElement = U.unsafeCoerce 347 | fromHTMLElement = fromAny H.readHTMLScriptElement 348 | 349 | instance isHTMLElementHTMLTemplateElement :: IsHTMLElement H.HTMLTemplateElement where 350 | toHTMLElement = U.unsafeCoerce 351 | fromHTMLElement = fromAny H.readHTMLTemplateElement 352 | 353 | instance isHTMLElementHTMLCanvasElement :: IsHTMLElement H.HTMLCanvasElement where 354 | toHTMLElement = U.unsafeCoerce 355 | fromHTMLElement = fromAny H.readHTMLCanvasElement 356 | -------------------------------------------------------------------------------- /src/DOM/Classy/Node.purs: -------------------------------------------------------------------------------- 1 | module DOM.Classy.Node where 2 | 3 | import Prelude 4 | 5 | import Control.Monad.Eff (Eff) 6 | 7 | import Data.Maybe (Maybe(..)) 8 | 9 | import DOM (DOM) 10 | import DOM.Classy.Util (fromAny) 11 | import DOM.HTML.Types as H 12 | import DOM.Node.Node as NN 13 | import DOM.Node.NodeType (NodeType) 14 | import DOM.Node.Types as N 15 | 16 | import Unsafe.Coerce as U 17 | 18 | -- | A class for subtypes of `Node`. 19 | class IsNode n where 20 | toNode :: n -> N.Node 21 | fromNode :: N.Node -> Maybe n 22 | 23 | -- | The type of a node. 24 | nodeType :: forall n. Partial => IsNode n => n -> NodeType 25 | nodeType = NN.nodeType <<< toNode 26 | 27 | -- | The numeric value for the type of a node. 28 | nodeTypeIndex :: forall n. IsNode n => n -> Int 29 | nodeTypeIndex = NN.nodeTypeIndex <<< toNode 30 | 31 | -- | For elements this is the tag name, for document types this is the doctype 32 | -- | name, for processing instructions this is the target, for all other nodes 33 | -- | it is a string like `"#text"`, `"#comment", etc. depending on the node 34 | -- | type. 35 | nodeName :: forall n. IsNode n => n -> String 36 | nodeName = NN.nodeName <<< toNode 37 | 38 | -- | The node's base URL. 39 | baseURI :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) String 40 | baseURI = NN.baseURI <<< toNode 41 | 42 | -- | The document the node belongs to, unless the node is a document in which 43 | -- | case the value is null. 44 | ownerDocument :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) (Maybe N.Document) 45 | ownerDocument = NN.ownerDocument <<< toNode 46 | 47 | -- | The parent node of the node. 48 | parentNode :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) (Maybe N.Node) 49 | parentNode = NN.parentNode <<< toNode 50 | 51 | -- | The parent element of the node. 52 | parentElement :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) (Maybe N.Element) 53 | parentElement = NN.parentElement <<< toNode 54 | 55 | -- | Indicates whether the node has any child nodes. 56 | hasChildNodes :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) Boolean 57 | hasChildNodes = NN.hasChildNodes <<< toNode 58 | 59 | -- | The children of the node. 60 | childNodes :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) N.NodeList 61 | childNodes = NN.childNodes <<< toNode 62 | 63 | -- | The first child of the node, or null if the node has no children. 64 | firstChild :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) (Maybe N.Node) 65 | firstChild = NN.firstChild <<< toNode 66 | 67 | -- | The last child of the node, or null if the node has no children. 68 | lastChild :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) (Maybe N.Node) 69 | lastChild = NN.lastChild <<< toNode 70 | 71 | -- | The previous sibling node, or null if there is no previous sibling. 72 | previousSibling :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) (Maybe N.Node) 73 | previousSibling = NN.previousSibling <<< toNode 74 | 75 | -- | The next sibling node, or null if there is no next sibling. 76 | nextSibling :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) (Maybe N.Node) 77 | nextSibling = NN.nextSibling <<< toNode 78 | 79 | -- | If the node type is text, comment, or processing instruction this is the 80 | -- | node's data, or null in all other cases. 81 | nodeValue :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) String 82 | nodeValue = NN.nodeValue <<< toNode 83 | 84 | -- | If the node type is text, comment, or processing instruction this allows 85 | -- | the node's data to be changed, or has no effect in all other cases. 86 | setNodeValue :: forall n eff. IsNode n => String -> n -> Eff (dom :: DOM | eff) Unit 87 | setNodeValue v = NN.setNodeValue v <<< toNode 88 | 89 | -- | If the node type is document fragment, element, text, processing 90 | -- | instruction, or comment this is the node's data, or null in all other 91 | -- | cases. 92 | textContent :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) String 93 | textContent = NN.textContent <<< toNode 94 | 95 | -- | If the node type is document fragment, element, text, processing 96 | -- | instruction, or comment this allows the node's data to be changed, or has 97 | -- | no effect in all other cases. 98 | setTextContent :: forall n eff. IsNode n => String -> n -> Eff (dom :: DOM | eff) Unit 99 | setTextContent tc = NN.setTextContent tc <<< toNode 100 | 101 | -- | Removes empty text nodes and then combines any remaining text nodes that 102 | -- | are contiguous. 103 | normalize :: forall n eff. IsNode n => n -> Eff (dom :: DOM | eff) Unit 104 | normalize = NN.normalize <<< toNode 105 | 106 | -- | Checks whether two nodes are equivalent. 107 | isEqualNode :: forall n1 n2 eff. IsNode n1 => IsNode n2 => n1 -> n2 -> Eff (dom :: DOM | eff) Boolean 108 | isEqualNode n1 n2 = NN.isEqualNode (toNode n1) (toNode n2) 109 | 110 | -- | Compares the position of two nodes in the document. 111 | compareDocumentPositionBits :: forall n1 n2 eff. IsNode n1 => IsNode n2 => n1 -> n2 -> Eff (dom :: DOM | eff) Int 112 | compareDocumentPositionBits n1 n2 = NN.compareDocumentPositionBits (toNode n1) (toNode n2) 113 | 114 | -- | Checks whether the second node is contained within the first 115 | contains :: forall n1 n2 eff. IsNode n1 => IsNode n2 => n1 -> n2 -> Eff (dom :: DOM | eff) Boolean 116 | contains n1 n2 = NN.contains (toNode n1) (toNode n2) 117 | 118 | lookupPrefix :: forall n eff. IsNode n => String -> n -> Eff (dom :: DOM | eff) (Maybe String) 119 | lookupPrefix s = NN.lookupPrefix s <<< toNode 120 | 121 | lookupNamespaceURI :: forall n eff. IsNode n => String -> n -> Eff (dom :: DOM | eff) (Maybe String) 122 | lookupNamespaceURI s = NN.lookupNamespaceURI s <<< toNode 123 | 124 | isDefaultNamespace :: forall n eff. IsNode n => String -> n -> Eff (dom :: DOM | eff) Boolean 125 | isDefaultNamespace s = NN.isDefaultNamespace s <<< toNode 126 | 127 | -- | Inserts the first node before the second as a child of the third node. 128 | insertBefore :: forall n1 n2 n3 eff. IsNode n1 => IsNode n2 => IsNode n3 => n1 -> n2 -> n3 -> Eff (dom :: DOM | eff) N.Node 129 | insertBefore n1 n2 n3 = NN.insertBefore (toNode n1) (toNode n2) (toNode n3) 130 | 131 | -- | Appends the first node to the child node list of the second node. 132 | appendChild :: forall n1 n2 eff. IsNode n1 => IsNode n2 => n1 -> n2 -> Eff (dom :: DOM | eff) N.Node 133 | appendChild n1 n2 = NN.appendChild (toNode n1) (toNode n2) 134 | 135 | -- | Uses the first node as a replacement for the second node in the children 136 | -- | of the third node. 137 | replaceChild :: forall n1 n2 n3 eff. IsNode n1 => IsNode n2 => IsNode n3 => n1 -> n2 -> n3 -> Eff (dom :: DOM | eff) N.Node 138 | replaceChild n1 n2 n3 = NN.replaceChild (toNode n1) (toNode n2) (toNode n3) 139 | 140 | -- | Removes the first node from the children of the second node. 141 | removeChild :: forall n1 n2 eff. IsNode n1 => IsNode n2 => n1 -> n2 -> Eff (dom :: DOM | eff) N.Node 142 | removeChild n1 n2 = NN.removeChild (toNode n1) (toNode n2) 143 | 144 | instance isNodeNode :: IsNode N.Node where 145 | toNode = U.unsafeCoerce 146 | fromNode = Just 147 | 148 | instance isNodeDocument :: IsNode N.Document where 149 | toNode = U.unsafeCoerce 150 | fromNode = fromAny N.readDocument 151 | 152 | instance isNodeElement :: IsNode N.Element where 153 | toNode = U.unsafeCoerce 154 | fromNode = fromAny N.readElement 155 | 156 | instance isNodeHTMLElement :: IsNode H.HTMLElement where 157 | toNode = U.unsafeCoerce 158 | fromNode = fromAny H.readHTMLElement 159 | 160 | instance isNodeHTMLHtmlElement :: IsNode H.HTMLHtmlElement where 161 | toNode = U.unsafeCoerce 162 | fromNode = fromAny H.readHTMLHtmlElement 163 | 164 | instance isNodeHTMLHeadElement :: IsNode H.HTMLHeadElement where 165 | toNode = U.unsafeCoerce 166 | fromNode = fromAny H.readHTMLHeadElement 167 | 168 | instance isNodeHTMLTitleElement :: IsNode H.HTMLTitleElement where 169 | toNode = U.unsafeCoerce 170 | fromNode = fromAny H.readHTMLTitleElement 171 | 172 | instance isNodeHTMLBaseElement :: IsNode H.HTMLBaseElement where 173 | toNode = U.unsafeCoerce 174 | fromNode = fromAny H.readHTMLBaseElement 175 | 176 | instance isNodeHTMLLinkElement :: IsNode H.HTMLLinkElement where 177 | toNode = U.unsafeCoerce 178 | fromNode = fromAny H.readHTMLLinkElement 179 | 180 | instance isNodeHTMLMetaElement :: IsNode H.HTMLMetaElement where 181 | toNode = U.unsafeCoerce 182 | fromNode = fromAny H.readHTMLMetaElement 183 | 184 | instance isNodeHTMLStyleElement :: IsNode H.HTMLStyleElement where 185 | toNode = U.unsafeCoerce 186 | fromNode = fromAny H.readHTMLStyleElement 187 | 188 | instance isNodeHTMLBodyElement :: IsNode H.HTMLBodyElement where 189 | toNode = U.unsafeCoerce 190 | fromNode = fromAny H.readHTMLBodyElement 191 | 192 | instance isNodeHTMLHeadingElement :: IsNode H.HTMLHeadingElement where 193 | toNode = U.unsafeCoerce 194 | fromNode = fromAny H.readHTMLHeadingElement 195 | 196 | instance isNodeHTMLParagraphElement :: IsNode H.HTMLParagraphElement where 197 | toNode = U.unsafeCoerce 198 | fromNode = fromAny H.readHTMLParagraphElement 199 | 200 | instance isNodeHTMLHRElement :: IsNode H.HTMLHRElement where 201 | toNode = U.unsafeCoerce 202 | fromNode = fromAny H.readHTMLHRElement 203 | 204 | instance isNodeHTMLPreElement :: IsNode H.HTMLPreElement where 205 | toNode = U.unsafeCoerce 206 | fromNode = fromAny H.readHTMLPreElement 207 | 208 | instance isNodeHTMLQuoteElement :: IsNode H.HTMLQuoteElement where 209 | toNode = U.unsafeCoerce 210 | fromNode = fromAny H.readHTMLQuoteElement 211 | 212 | instance isNodeHTMLOListElement :: IsNode H.HTMLOListElement where 213 | toNode = U.unsafeCoerce 214 | fromNode = fromAny H.readHTMLOListElement 215 | 216 | instance isNodeHTMLUListElement :: IsNode H.HTMLUListElement where 217 | toNode = U.unsafeCoerce 218 | fromNode = fromAny H.readHTMLUListElement 219 | 220 | instance isNodeHTMLLIElement :: IsNode H.HTMLLIElement where 221 | toNode = U.unsafeCoerce 222 | fromNode = fromAny H.readHTMLLIElement 223 | 224 | instance isNodeHTMLDListElement :: IsNode H.HTMLDListElement where 225 | toNode = U.unsafeCoerce 226 | fromNode = fromAny H.readHTMLDListElement 227 | 228 | instance isNodeHTMLDivElement :: IsNode H.HTMLDivElement where 229 | toNode = U.unsafeCoerce 230 | fromNode = fromAny H.readHTMLDivElement 231 | 232 | instance isNodeHTMLAnchorElement :: IsNode H.HTMLAnchorElement where 233 | toNode = U.unsafeCoerce 234 | fromNode = fromAny H.readHTMLAnchorElement 235 | 236 | instance isNodeHTMLDataElement :: IsNode H.HTMLDataElement where 237 | toNode = U.unsafeCoerce 238 | fromNode = fromAny H.readHTMLDataElement 239 | 240 | instance isNodeHTMLTimeElement :: IsNode H.HTMLTimeElement where 241 | toNode = U.unsafeCoerce 242 | fromNode = fromAny H.readHTMLTimeElement 243 | 244 | instance isNodeHTMLSpanElement :: IsNode H.HTMLSpanElement where 245 | toNode = U.unsafeCoerce 246 | fromNode = fromAny H.readHTMLSpanElement 247 | 248 | instance isNodeHTMLBRElement :: IsNode H.HTMLBRElement where 249 | toNode = U.unsafeCoerce 250 | fromNode = fromAny H.readHTMLBRElement 251 | 252 | instance isNodeHTMLModElement :: IsNode H.HTMLModElement where 253 | toNode = U.unsafeCoerce 254 | fromNode = fromAny H.readHTMLModElement 255 | 256 | instance isNodeHTMLImageElement :: IsNode H.HTMLImageElement where 257 | toNode = U.unsafeCoerce 258 | fromNode = fromAny H.readHTMLImageElement 259 | 260 | instance isNodeHTMLIFrameElement :: IsNode H.HTMLIFrameElement where 261 | toNode = U.unsafeCoerce 262 | fromNode = fromAny H.readHTMLIFrameElement 263 | 264 | instance isNodeHTMLEmbedElement :: IsNode H.HTMLEmbedElement where 265 | toNode = U.unsafeCoerce 266 | fromNode = fromAny H.readHTMLEmbedElement 267 | 268 | instance isNodeHTMLObjectElement :: IsNode H.HTMLObjectElement where 269 | toNode = U.unsafeCoerce 270 | fromNode = fromAny H.readHTMLObjectElement 271 | 272 | instance isNodeHTMLParamElement :: IsNode H.HTMLParamElement where 273 | toNode = U.unsafeCoerce 274 | fromNode = fromAny H.readHTMLParamElement 275 | 276 | instance isNodeHTMLMediaElement :: IsNode H.HTMLMediaElement where 277 | toNode = U.unsafeCoerce 278 | fromNode = fromAny H.readHTMLMediaElement 279 | 280 | instance isNodeHTMLAudioElement :: IsNode H.HTMLAudioElement where 281 | toNode = U.unsafeCoerce 282 | fromNode = fromAny H.readHTMLAudioElement 283 | 284 | instance isNodeHTMLVideoElement :: IsNode H.HTMLVideoElement where 285 | toNode = U.unsafeCoerce 286 | fromNode = fromAny H.readHTMLVideoElement 287 | 288 | instance isNodeHTMLSourceElement :: IsNode H.HTMLSourceElement where 289 | toNode = U.unsafeCoerce 290 | fromNode = fromAny H.readHTMLSourceElement 291 | 292 | instance isNodeHTMLTrackElement :: IsNode H.HTMLTrackElement where 293 | toNode = U.unsafeCoerce 294 | fromNode = fromAny H.readHTMLTrackElement 295 | 296 | instance isNodeHTMLMapElement :: IsNode H.HTMLMapElement where 297 | toNode = U.unsafeCoerce 298 | fromNode = fromAny H.readHTMLMapElement 299 | 300 | instance isNodeHTMLAreaElement :: IsNode H.HTMLAreaElement where 301 | toNode = U.unsafeCoerce 302 | fromNode = fromAny H.readHTMLAreaElement 303 | 304 | instance isNodeHTMLTableElement :: IsNode H.HTMLTableElement where 305 | toNode = U.unsafeCoerce 306 | fromNode = fromAny H.readHTMLTableElement 307 | 308 | instance isNodeHTMLTableCaptionElement :: IsNode H.HTMLTableCaptionElement where 309 | toNode = U.unsafeCoerce 310 | fromNode = fromAny H.readHTMLTableCaptionElement 311 | 312 | instance isNodeHTMLTableColElement :: IsNode H.HTMLTableColElement where 313 | toNode = U.unsafeCoerce 314 | fromNode = fromAny H.readHTMLTableColElement 315 | 316 | instance isNodeHTMLTableSectionElement :: IsNode H.HTMLTableSectionElement where 317 | toNode = U.unsafeCoerce 318 | fromNode = fromAny H.readHTMLTableSectionElement 319 | 320 | instance isNodeHTMLTableRowElement :: IsNode H.HTMLTableRowElement where 321 | toNode = U.unsafeCoerce 322 | fromNode = fromAny H.readHTMLTableRowElement 323 | 324 | instance isNodeHTMLTableCellElement :: IsNode H.HTMLTableCellElement where 325 | toNode = U.unsafeCoerce 326 | fromNode = fromAny H.readHTMLTableCellElement 327 | 328 | instance isNodeHTMLTableDataCellElement :: IsNode H.HTMLTableDataCellElement where 329 | toNode = U.unsafeCoerce 330 | fromNode = fromAny H.readHTMLTableDataCellElement 331 | 332 | instance isNodeHTMLTableHeaderCellElement :: IsNode H.HTMLTableHeaderCellElement where 333 | toNode = U.unsafeCoerce 334 | fromNode = fromAny H.readHTMLTableHeaderCellElement 335 | 336 | instance isNodeHTMLFormElement :: IsNode H.HTMLFormElement where 337 | toNode = U.unsafeCoerce 338 | fromNode = fromAny H.readHTMLFormElement 339 | 340 | instance isNodeHTMLLabelElement :: IsNode H.HTMLLabelElement where 341 | toNode = U.unsafeCoerce 342 | fromNode = fromAny H.readHTMLLabelElement 343 | 344 | instance isNodeHTMLInputElement :: IsNode H.HTMLInputElement where 345 | toNode = U.unsafeCoerce 346 | fromNode = fromAny H.readHTMLInputElement 347 | 348 | instance isNodeHTMLButtonElement :: IsNode H.HTMLButtonElement where 349 | toNode = U.unsafeCoerce 350 | fromNode = fromAny H.readHTMLButtonElement 351 | 352 | instance isNodeHTMLSelectElement :: IsNode H.HTMLSelectElement where 353 | toNode = U.unsafeCoerce 354 | fromNode = fromAny H.readHTMLSelectElement 355 | 356 | instance isNodeHTMLDataListElement :: IsNode H.HTMLDataListElement where 357 | toNode = U.unsafeCoerce 358 | fromNode = fromAny H.readHTMLDataListElement 359 | 360 | instance isNodeHTMLOptGroupElement :: IsNode H.HTMLOptGroupElement where 361 | toNode = U.unsafeCoerce 362 | fromNode = fromAny H.readHTMLOptGroupElement 363 | 364 | instance isNodeHTMLOptionElement :: IsNode H.HTMLOptionElement where 365 | toNode = U.unsafeCoerce 366 | fromNode = fromAny H.readHTMLOptionElement 367 | 368 | instance isNodeHTMLTextAreaElement :: IsNode H.HTMLTextAreaElement where 369 | toNode = U.unsafeCoerce 370 | fromNode = fromAny H.readHTMLTextAreaElement 371 | 372 | instance isNodeHTMLKeygenElement :: IsNode H.HTMLKeygenElement where 373 | toNode = U.unsafeCoerce 374 | fromNode = fromAny H.readHTMLKeygenElement 375 | 376 | instance isNodeHTMLOutputElement :: IsNode H.HTMLOutputElement where 377 | toNode = U.unsafeCoerce 378 | fromNode = fromAny H.readHTMLOutputElement 379 | 380 | instance isNodeHTMLProgressElement :: IsNode H.HTMLProgressElement where 381 | toNode = U.unsafeCoerce 382 | fromNode = fromAny H.readHTMLProgressElement 383 | 384 | instance isNodeHTMLMeterElement :: IsNode H.HTMLMeterElement where 385 | toNode = U.unsafeCoerce 386 | fromNode = fromAny H.readHTMLMeterElement 387 | 388 | instance isNodeHTMLFieldSetElement :: IsNode H.HTMLFieldSetElement where 389 | toNode = U.unsafeCoerce 390 | fromNode = fromAny H.readHTMLFieldSetElement 391 | 392 | instance isNodeHTMLLegendElement :: IsNode H.HTMLLegendElement where 393 | toNode = U.unsafeCoerce 394 | fromNode = fromAny H.readHTMLLegendElement 395 | 396 | instance isNodeHTMLScriptElement :: IsNode H.HTMLScriptElement where 397 | toNode = U.unsafeCoerce 398 | fromNode = fromAny H.readHTMLScriptElement 399 | 400 | instance isNodeHTMLTemplateElement :: IsNode H.HTMLTemplateElement where 401 | toNode = U.unsafeCoerce 402 | fromNode = fromAny H.readHTMLTemplateElement 403 | 404 | instance isNodeHTMLCanvasElement :: IsNode H.HTMLCanvasElement where 405 | toNode = U.unsafeCoerce 406 | fromNode = fromAny H.readHTMLCanvasElement 407 | --------------------------------------------------------------------------------