dom.nim 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2012 Andreas Rumpf
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. ## Declaration of the Document Object Model for the `JavaScript backend
  10. ## <backends.html#backends-the-javascript-target>`_.
  11. ##
  12. ##
  13. ## Document Ready
  14. ## --------------
  15. ##
  16. ## * Basic example of a document ready:
  17. runnableExamples"-b:js -r:off":
  18. proc example(e: Event) = echo "Document is ready"
  19. document.addEventListener("DOMContentLoaded", example) # You can also use "load" event.
  20. ## * This example runs 5 seconds after the document ready:
  21. runnableExamples"-b:js -r:off":
  22. proc example() = echo "5 seconds after document ready"
  23. proc domReady(e: Event) = discard setTimeout(example, 5_000) # Document is ready.
  24. document.addEventListener("DOMContentLoaded", domReady)
  25. ## Document onUnload
  26. ## -----------------
  27. ##
  28. ## * Simple example of how to implement code that runs when the page unloads:
  29. runnableExamples"-b:js -r:off":
  30. proc example(e: Event) = echo "Document is unloaded"
  31. document.addEventListener("unload", example) # You can also use "beforeunload".
  32. ## Document Autorefresh
  33. ## --------------------
  34. ##
  35. ## * Minimal example of a document autorefresh:
  36. runnableExamples"-b:js -r:off":
  37. proc example() = window.location.reload()
  38. discard setTimeout(example, 5_000)
  39. ## - For more examples, see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
  40. import std/private/since
  41. when not defined(js):
  42. {.error: "This module only works on the JavaScript platform".}
  43. const
  44. DomApiVersion* = 3 ## the version of DOM API we try to follow. No guarantees though.
  45. type
  46. EventTarget* {.importc.} = ref object of RootObj
  47. onabort*: proc (event: Event) {.closure.}
  48. onblur*: proc (event: Event) {.closure.}
  49. onchange*: proc (event: Event) {.closure.}
  50. onclick*: proc (event: Event) {.closure.}
  51. ondblclick*: proc (event: Event) {.closure.}
  52. onerror*: proc (event: Event) {.closure.}
  53. onfocus*: proc (event: Event) {.closure.}
  54. onkeydown*: proc (event: Event) {.closure.}
  55. onkeypress*: proc (event: Event) {.closure.}
  56. onkeyup*: proc (event: Event) {.closure.}
  57. onload*: proc (event: Event) {.closure.}
  58. onmousedown*: proc (event: Event) {.closure.}
  59. onmousemove*: proc (event: Event) {.closure.}
  60. onmouseout*: proc (event: Event) {.closure.}
  61. onmouseover*: proc (event: Event) {.closure.}
  62. onmouseup*: proc (event: Event) {.closure.}
  63. onreset*: proc (event: Event) {.closure.}
  64. onselect*: proc (event: Event) {.closure.}
  65. onstorage*: proc (event: Event) {.closure.}
  66. onsubmit*: proc (event: Event) {.closure.}
  67. onunload*: proc (event: Event) {.closure.}
  68. onloadstart*: proc (event: Event) {.closure.}
  69. onprogress*: proc (event: Event) {.closure.}
  70. onloadend*: proc (event: Event) {.closure.}
  71. DomEvent* {.pure.} = enum
  72. ## see `docs<https://developer.mozilla.org/en-US/docs/Web/Events>`_
  73. Abort = "abort",
  74. BeforeInput = "beforeinput",
  75. Blur = "blur",
  76. Click = "click",
  77. CompositionEnd = "compositionend",
  78. CompositionStart = "compositionstart",
  79. CompositionUpdate = "compositionupdate",
  80. DblClick = "dblclick",
  81. Error = "error",
  82. Focus = "focus",
  83. FocusIn = "focusin",
  84. FocusOut = "focusout",
  85. Input = "input",
  86. KeyDown = "keydown",
  87. KeyPress = "keypress",
  88. KeyUp = "keyup",
  89. Load = "load",
  90. MouseDown = "mousedown",
  91. MouseEnter = "mouseenter",
  92. MouseLeave = "mouseleave",
  93. MouseMove = "mousemove",
  94. MouseOut = "mouseout",
  95. MouseOver = "mouseover",
  96. MouseUp = "mouseup",
  97. Resize = "resize",
  98. Scroll = "scroll",
  99. Select = "select",
  100. Storage = "storage",
  101. Unload = "unload",
  102. Wheel = "wheel"
  103. PerformanceMemory* {.importc.} = ref object
  104. jsHeapSizeLimit*: float
  105. totalJSHeapSize*: float
  106. usedJSHeapSize*: float
  107. PerformanceTiming* {.importc.} = ref object
  108. connectStart*: float
  109. domComplete*: float
  110. domContentLoadedEventEnd*: float
  111. domContentLoadedEventStart*: float
  112. domInteractive*: float
  113. domLoading*: float
  114. domainLookupEnd*: float
  115. domainLookupStart*: float
  116. fetchStart*: float
  117. loadEventEnd*: float
  118. loadEventStart*: float
  119. navigationStart*: float
  120. redirectEnd*: float
  121. redirectStart*: float
  122. requestStart*: float
  123. responseEnd*: float
  124. responseStart*: float
  125. secureConnectionStart*: float
  126. unloadEventEnd*: float
  127. unloadEventStart*: float
  128. Performance* {.importc.} = ref object
  129. memory*: PerformanceMemory
  130. timing*: PerformanceTiming
  131. Range* {.importc.} = ref object
  132. ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Range>`_
  133. collapsed*: bool
  134. commonAncestorContainer*: Node
  135. endContainer*: Node
  136. endOffset*: int
  137. startContainer*: Node
  138. startOffset*: int
  139. Selection* {.importc.} = ref object
  140. ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Selection>`_
  141. anchorNode*: Node
  142. anchorOffset*: int
  143. focusNode*: Node
  144. focusOffset*: int
  145. isCollapsed*: bool
  146. rangeCount*: int
  147. `type`*: cstring
  148. Storage* {.importc.} = ref object
  149. Window* {.importc.} = ref object of EventTarget
  150. document*: Document
  151. event*: Event
  152. history*: History
  153. location*: Location
  154. closed*: bool
  155. defaultStatus*: cstring
  156. devicePixelRatio*: float
  157. innerHeight*, innerWidth*: int
  158. locationbar*: ref LocationBar
  159. menubar*: ref MenuBar
  160. name*: cstring
  161. outerHeight*, outerWidth*: int
  162. pageXOffset*, pageYOffset*: int
  163. scrollX*: float
  164. scrollY*: float
  165. personalbar*: ref PersonalBar
  166. scrollbars*: ref ScrollBars
  167. statusbar*: ref StatusBar
  168. status*: cstring
  169. toolbar*: ref ToolBar
  170. frames*: seq[Frame]
  171. screen*: Screen
  172. performance*: Performance
  173. onpopstate*: proc (event: Event)
  174. localStorage*: Storage
  175. sessionStorage*: Storage
  176. parent*: Window
  177. Frame* {.importc.} = ref object of Window
  178. ClassList* {.importc.} = ref object of RootObj
  179. NodeType* = enum
  180. ElementNode = 1,
  181. AttributeNode,
  182. TextNode,
  183. CDATANode,
  184. EntityRefNode,
  185. EntityNode,
  186. ProcessingInstructionNode,
  187. CommentNode,
  188. DocumentNode,
  189. DocumentTypeNode,
  190. DocumentFragmentNode,
  191. NotationNode
  192. Node* {.importc.} = ref object of EventTarget
  193. attributes*: seq[Node]
  194. childNodes*: seq[Node]
  195. children*: seq[Node]
  196. data*: cstring
  197. firstChild*: Node
  198. lastChild*: Node
  199. nextSibling*: Node
  200. nodeName*: cstring
  201. nodeType*: NodeType
  202. nodeValue*: cstring
  203. parentNode*: Node
  204. content*: Node
  205. previousSibling*: Node
  206. ownerDocument*: Document
  207. innerHTML*: cstring
  208. outerHTML*: cstring
  209. innerText*: cstring
  210. textContent*: cstring
  211. style*: Style
  212. baseURI*: cstring
  213. parentElement*: Element
  214. isConnected*: bool
  215. Document* {.importc.} = ref object of Node
  216. activeElement*: Element
  217. documentElement*: Element
  218. alinkColor*: cstring
  219. bgColor*: cstring
  220. body*: Element
  221. charset*: cstring
  222. cookie*: cstring
  223. defaultCharset*: cstring
  224. fgColor*: cstring
  225. head*: Element
  226. hidden*: bool
  227. lastModified*: cstring
  228. linkColor*: cstring
  229. referrer*: cstring
  230. title*: cstring
  231. URL*: cstring
  232. visibilityState*: cstring
  233. vlinkColor*: cstring
  234. anchors*: seq[AnchorElement]
  235. forms*: seq[FormElement]
  236. images*: seq[ImageElement]
  237. applets*: seq[Element]
  238. embeds*: seq[EmbedElement]
  239. links*: seq[LinkElement]
  240. fonts*: FontFaceSet
  241. Element* {.importc.} = ref object of Node
  242. className*: cstring
  243. classList*: ClassList
  244. checked*: bool
  245. defaultChecked*: bool
  246. defaultValue*: cstring
  247. disabled*: bool
  248. form*: FormElement
  249. name*: cstring
  250. readOnly*: bool
  251. options*: seq[OptionElement]
  252. selectedOptions*: seq[OptionElement]
  253. clientWidth*, clientHeight*: int
  254. contentEditable*: cstring
  255. isContentEditable*: bool
  256. dir*: cstring
  257. offsetHeight*: int
  258. offsetWidth*: int
  259. offsetLeft*: int
  260. offsetTop*: int
  261. ValidityState* {.importc.} = ref object ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/ValidityState>`_
  262. badInput*: bool
  263. customError*: bool
  264. patternMismatch*: bool
  265. rangeOverflow*: bool
  266. rangeUnderflow*: bool
  267. stepMismatch*: bool
  268. tooLong*: bool
  269. tooShort*: bool
  270. typeMismatch*: bool
  271. valid*: bool
  272. valueMissing*: bool
  273. Blob* {.importc.} = ref object of RootObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Blob>`_
  274. size*: int
  275. `type`*: cstring
  276. File* {.importc.} = ref object of Blob ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/File>`_
  277. lastModified*: int
  278. name*: cstring
  279. TextAreaElement* {.importc.} = ref object of Element ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement>`_
  280. value*: cstring
  281. selectionStart*, selectionEnd*: int
  282. selectionDirection*: cstring
  283. rows*, cols*: int
  284. InputElement* {.importc.} = ref object of Element ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement>`_
  285. # Properties related to the parent form
  286. formAction*: cstring
  287. formEncType*: cstring
  288. formMethod*: cstring
  289. formNoValidate*: bool
  290. formTarget*: cstring
  291. # Properties that apply to any type of input element that is not hidden
  292. `type`*: cstring
  293. autofocus*: bool
  294. required*: bool
  295. value*: cstring
  296. validity*: ValidityState
  297. validationMessage*: cstring
  298. willValidate*: bool
  299. # Properties that apply only to elements of type "checkbox" or "radio"
  300. indeterminate*: bool
  301. # Properties that apply only to elements of type "image"
  302. alt*: cstring
  303. height*: cstring
  304. src*: cstring
  305. width*: cstring
  306. # Properties that apply only to elements of type "file"
  307. accept*: cstring
  308. files*: seq[Blob]
  309. # Properties that apply only to text/number-containing or elements
  310. autocomplete*: cstring
  311. maxLength*: int
  312. size*: int
  313. pattern*: cstring
  314. placeholder*: cstring
  315. min*: cstring
  316. max*: cstring
  317. selectionStart*: int
  318. selectionEnd*: int
  319. selectionDirection*: cstring
  320. # Properties not yet categorized
  321. dirName*: cstring
  322. accessKey*: cstring
  323. list*: Element
  324. multiple*: bool
  325. labels*: seq[Element]
  326. step*: cstring
  327. valueAsDate*: cstring
  328. valueAsNumber*: float
  329. LinkElement* {.importc.} = ref object of Element
  330. target*: cstring
  331. text*: cstring
  332. x*: int
  333. y*: int
  334. EmbedElement* {.importc.} = ref object of Element
  335. height*: int
  336. hspace*: int
  337. src*: cstring
  338. width*: int
  339. `type`*: cstring
  340. vspace*: int
  341. AnchorElement* {.importc.} = ref object of Element
  342. text*: cstring
  343. x*, y*: int
  344. OptionElement* {.importc.} = ref object of Element
  345. defaultSelected*: bool
  346. selected*: bool
  347. selectedIndex*: int
  348. text*: cstring
  349. value*: cstring
  350. FormElement* {.importc.} = ref object of Element ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement>`_
  351. acceptCharset*: cstring
  352. action*: cstring
  353. autocomplete*: cstring
  354. elements*: seq[Element]
  355. encoding*: cstring
  356. enctype*: cstring
  357. length*: int
  358. `method`*: cstring
  359. noValidate*: bool
  360. target*: cstring
  361. ImageElement* {.importc.} = ref object of Element
  362. border*: int
  363. complete*: bool
  364. height*: int
  365. hspace*: int
  366. lowsrc*: cstring
  367. src*: cstring
  368. vspace*: int
  369. width*: int
  370. Style* {.importc.} = ref object of RootObj
  371. alignContent*: cstring
  372. alignItems*: cstring
  373. alignSelf*: cstring
  374. all*: cstring
  375. animation*: cstring
  376. animationDelay*: cstring
  377. animationDirection*: cstring
  378. animationDuration*: cstring
  379. animationFillMode*: cstring
  380. animationIterationCount*: cstring
  381. animationName*: cstring
  382. animationPlayState*: cstring
  383. animationTimingFunction*: cstring
  384. backdropFilter*: cstring
  385. backfaceVisibility*: cstring
  386. background*: cstring
  387. backgroundAttachment*: cstring
  388. backgroundBlendMode*: cstring
  389. backgroundClip*: cstring
  390. backgroundColor*: cstring
  391. backgroundImage*: cstring
  392. backgroundOrigin*: cstring
  393. backgroundPosition*: cstring
  394. backgroundRepeat*: cstring
  395. backgroundSize*: cstring
  396. blockSize*: cstring
  397. border*: cstring
  398. borderBlock*: cstring
  399. borderBlockColor*: cstring
  400. borderBlockEnd*: cstring
  401. borderBlockEndColor*: cstring
  402. borderBlockEndStyle*: cstring
  403. borderBlockEndWidth*: cstring
  404. borderBlockStart*: cstring
  405. borderBlockStartColor*: cstring
  406. borderBlockStartStyle*: cstring
  407. borderBlockStartWidth*: cstring
  408. borderBlockStyle*: cstring
  409. borderBlockWidth*: cstring
  410. borderBottom*: cstring
  411. borderBottomColor*: cstring
  412. borderBottomLeftRadius*: cstring
  413. borderBottomRightRadius*: cstring
  414. borderBottomStyle*: cstring
  415. borderBottomWidth*: cstring
  416. borderCollapse*: cstring
  417. borderColor*: cstring
  418. borderEndEndRadius*: cstring
  419. borderEndStartRadius*: cstring
  420. borderImage*: cstring
  421. borderImageOutset*: cstring
  422. borderImageRepeat*: cstring
  423. borderImageSlice*: cstring
  424. borderImageSource*: cstring
  425. borderImageWidth*: cstring
  426. borderInline*: cstring
  427. borderInlineColor*: cstring
  428. borderInlineEnd*: cstring
  429. borderInlineEndColor*: cstring
  430. borderInlineEndStyle*: cstring
  431. borderInlineEndWidth*: cstring
  432. borderInlineStart*: cstring
  433. borderInlineStartColor*: cstring
  434. borderInlineStartStyle*: cstring
  435. borderInlineStartWidth*: cstring
  436. borderInlineStyle*: cstring
  437. borderInlineWidth*: cstring
  438. borderLeft*: cstring
  439. borderLeftColor*: cstring
  440. borderLeftStyle*: cstring
  441. borderLeftWidth*: cstring
  442. borderRadius*: cstring
  443. borderRight*: cstring
  444. borderRightColor*: cstring
  445. borderRightStyle*: cstring
  446. borderRightWidth*: cstring
  447. borderSpacing*: cstring
  448. borderStartEndRadius*: cstring
  449. borderStartStartRadius*: cstring
  450. borderStyle*: cstring
  451. borderTop*: cstring
  452. borderTopColor*: cstring
  453. borderTopLeftRadius*: cstring
  454. borderTopRightRadius*: cstring
  455. borderTopStyle*: cstring
  456. borderTopWidth*: cstring
  457. borderWidth*: cstring
  458. bottom*: cstring
  459. boxDecorationBreak*: cstring
  460. boxShadow*: cstring
  461. boxSizing*: cstring
  462. breakAfter*: cstring
  463. breakBefore*: cstring
  464. breakInside*: cstring
  465. captionSide*: cstring
  466. caretColor*: cstring
  467. clear*: cstring
  468. clip*: cstring
  469. clipPath*: cstring
  470. color*: cstring
  471. colorAdjust*: cstring
  472. columnCount*: cstring
  473. columnFill*: cstring
  474. columnGap*: cstring
  475. columnRule*: cstring
  476. columnRuleColor*: cstring
  477. columnRuleStyle*: cstring
  478. columnRuleWidth*: cstring
  479. columnSpan*: cstring
  480. columnWidth*: cstring
  481. columns*: cstring
  482. contain*: cstring
  483. content*: cstring
  484. counterIncrement*: cstring
  485. counterReset*: cstring
  486. counterSet*: cstring
  487. cursor*: cstring
  488. direction*: cstring
  489. display*: cstring
  490. emptyCells*: cstring
  491. filter*: cstring
  492. flex*: cstring
  493. flexBasis*: cstring
  494. flexDirection*: cstring
  495. flexFlow*: cstring
  496. flexGrow*: cstring
  497. flexShrink*: cstring
  498. flexWrap*: cstring
  499. cssFloat*: cstring
  500. font*: cstring
  501. fontFamily*: cstring
  502. fontFeatureSettings*: cstring
  503. fontKerning*: cstring
  504. fontLanguageOverride*: cstring
  505. fontOpticalSizing*: cstring
  506. fontSize*: cstring
  507. fontSizeAdjust*: cstring
  508. fontStretch*: cstring
  509. fontStyle*: cstring
  510. fontSynthesis*: cstring
  511. fontVariant*: cstring
  512. fontVariantAlternates*: cstring
  513. fontVariantCaps*: cstring
  514. fontVariantEastAsian*: cstring
  515. fontVariantLigatures*: cstring
  516. fontVariantNumeric*: cstring
  517. fontVariantPosition*: cstring
  518. fontVariationSettings*: cstring
  519. fontWeight*: cstring
  520. gap*: cstring
  521. grid*: cstring
  522. gridArea*: cstring
  523. gridAutoColumns*: cstring
  524. gridAutoFlow*: cstring
  525. gridAutoRows*: cstring
  526. gridColumn*: cstring
  527. gridColumnEnd*: cstring
  528. gridColumnStart*: cstring
  529. gridRow*: cstring
  530. gridRowEnd*: cstring
  531. gridRowStart*: cstring
  532. gridTemplate*: cstring
  533. gridTemplateAreas*: cstring
  534. gridTemplateColumns*: cstring
  535. gridTemplateRows*: cstring
  536. hangingPunctuation*: cstring
  537. height*: cstring
  538. hyphens*: cstring
  539. imageOrientation*: cstring
  540. imageRendering*: cstring
  541. inlineSize*: cstring
  542. inset*: cstring
  543. insetBlock*: cstring
  544. insetBlockEnd*: cstring
  545. insetBlockStart*: cstring
  546. insetInline*: cstring
  547. insetInlineEnd*: cstring
  548. insetInlineStart*: cstring
  549. isolation*: cstring
  550. justifyContent*: cstring
  551. justifyItems*: cstring
  552. justifySelf*: cstring
  553. left*: cstring
  554. letterSpacing*: cstring
  555. lineBreak*: cstring
  556. lineHeight*: cstring
  557. listStyle*: cstring
  558. listStyleImage*: cstring
  559. listStylePosition*: cstring
  560. listStyleType*: cstring
  561. margin*: cstring
  562. marginBlock*: cstring
  563. marginBlockEnd*: cstring
  564. marginBlockStart*: cstring
  565. marginBottom*: cstring
  566. marginInline*: cstring
  567. marginInlineEnd*: cstring
  568. marginInlineStart*: cstring
  569. marginLeft*: cstring
  570. marginRight*: cstring
  571. marginTop*: cstring
  572. mask*: cstring
  573. maskBorder*: cstring
  574. maskBorderMode*: cstring
  575. maskBorderOutset*: cstring
  576. maskBorderRepeat*: cstring
  577. maskBorderSlice*: cstring
  578. maskBorderSource*: cstring
  579. maskBorderWidth*: cstring
  580. maskClip*: cstring
  581. maskComposite*: cstring
  582. maskImage*: cstring
  583. maskMode*: cstring
  584. maskOrigin*: cstring
  585. maskPosition*: cstring
  586. maskRepeat*: cstring
  587. maskSize*: cstring
  588. maskType*: cstring
  589. maxBlockSize*: cstring
  590. maxHeight*: cstring
  591. maxInlineSize*: cstring
  592. maxWidth*: cstring
  593. minBlockSize*: cstring
  594. minHeight*: cstring
  595. minInlineSize*: cstring
  596. minWidth*: cstring
  597. mixBlendMode*: cstring
  598. objectFit*: cstring
  599. objectPosition*: cstring
  600. offset*: cstring
  601. offsetAnchor*: cstring
  602. offsetDistance*: cstring
  603. offsetPath*: cstring
  604. offsetRotate*: cstring
  605. opacity*: cstring
  606. order*: cstring
  607. orphans*: cstring
  608. outline*: cstring
  609. outlineColor*: cstring
  610. outlineOffset*: cstring
  611. outlineStyle*: cstring
  612. outlineWidth*: cstring
  613. overflow*: cstring
  614. overflowAnchor*: cstring
  615. overflowBlock*: cstring
  616. overflowInline*: cstring
  617. overflowWrap*: cstring
  618. overflowX*: cstring
  619. overflowY*: cstring
  620. overscrollBehavior*: cstring
  621. overscrollBehaviorBlock*: cstring
  622. overscrollBehaviorInline*: cstring
  623. overscrollBehaviorX*: cstring
  624. overscrollBehaviorY*: cstring
  625. padding*: cstring
  626. paddingBlock*: cstring
  627. paddingBlockEnd*: cstring
  628. paddingBlockStart*: cstring
  629. paddingBottom*: cstring
  630. paddingInline*: cstring
  631. paddingInlineEnd*: cstring
  632. paddingInlineStart*: cstring
  633. paddingLeft*: cstring
  634. paddingRight*: cstring
  635. paddingTop*: cstring
  636. pageBreakAfter*: cstring
  637. pageBreakBefore*: cstring
  638. pageBreakInside*: cstring
  639. paintOrder*: cstring
  640. perspective*: cstring
  641. perspectiveOrigin*: cstring
  642. placeContent*: cstring
  643. placeItems*: cstring
  644. placeSelf*: cstring
  645. pointerEvents*: cstring
  646. position*: cstring
  647. quotes*: cstring
  648. resize*: cstring
  649. right*: cstring
  650. rotate*: cstring
  651. rowGap*: cstring
  652. scale*: cstring
  653. scrollBehavior*: cstring
  654. scrollMargin*: cstring
  655. scrollMarginBlock*: cstring
  656. scrollMarginBlockEnd*: cstring
  657. scrollMarginBlockStart*: cstring
  658. scrollMarginBottom*: cstring
  659. scrollMarginInline*: cstring
  660. scrollMarginInlineEnd*: cstring
  661. scrollMarginInlineStart*: cstring
  662. scrollMarginLeft*: cstring
  663. scrollMarginRight*: cstring
  664. scrollMarginTop*: cstring
  665. scrollPadding*: cstring
  666. scrollPaddingBlock*: cstring
  667. scrollPaddingBlockEnd*: cstring
  668. scrollPaddingBlockStart*: cstring
  669. scrollPaddingBottom*: cstring
  670. scrollPaddingInline*: cstring
  671. scrollPaddingInlineEnd*: cstring
  672. scrollPaddingInlineStart*: cstring
  673. scrollPaddingLeft*: cstring
  674. scrollPaddingRight*: cstring
  675. scrollPaddingTop*: cstring
  676. scrollSnapAlign*: cstring
  677. scrollSnapStop*: cstring
  678. scrollSnapType*: cstring
  679. scrollbar3dLightColor*: cstring
  680. scrollbarArrowColor*: cstring
  681. scrollbarBaseColor*: cstring
  682. scrollbarColor*: cstring
  683. scrollbarDarkshadowColor*: cstring
  684. scrollbarFaceColor*: cstring
  685. scrollbarHighlightColor*: cstring
  686. scrollbarShadowColor*: cstring
  687. scrollbarTrackColor*: cstring
  688. scrollbarWidth*: cstring
  689. shapeImageThreshold*: cstring
  690. shapeMargin*: cstring
  691. shapeOutside*: cstring
  692. tabSize*: cstring
  693. tableLayout*: cstring
  694. textAlign*: cstring
  695. textAlignLast*: cstring
  696. textCombineUpright*: cstring
  697. textDecoration*: cstring
  698. textDecorationColor*: cstring
  699. textDecorationLine*: cstring
  700. textDecorationSkipInk*: cstring
  701. textDecorationStyle*: cstring
  702. textDecorationThickness*: cstring
  703. textEmphasis*: cstring
  704. textEmphasisColor*: cstring
  705. textEmphasisPosition*: cstring
  706. textEmphasisStyle*: cstring
  707. textIndent*: cstring
  708. textJustify*: cstring
  709. textOrientation*: cstring
  710. textOverflow*: cstring
  711. textRendering*: cstring
  712. textShadow*: cstring
  713. textTransform*: cstring
  714. textUnderlineOffset*: cstring
  715. textUnderlinePosition*: cstring
  716. top*: cstring
  717. touchAction*: cstring
  718. transform*: cstring
  719. transformBox*: cstring
  720. transformOrigin*: cstring
  721. transformStyle*: cstring
  722. transition*: cstring
  723. transitionDelay*: cstring
  724. transitionDuration*: cstring
  725. transitionProperty*: cstring
  726. transitionTimingFunction*: cstring
  727. translate*: cstring
  728. unicodeBidi*: cstring
  729. verticalAlign*: cstring
  730. visibility*: cstring
  731. whiteSpace*: cstring
  732. widows*: cstring
  733. width*: cstring
  734. willChange*: cstring
  735. wordBreak*: cstring
  736. wordSpacing*: cstring
  737. writingMode*: cstring
  738. zIndex*: cstring
  739. EventPhase* = enum
  740. None = 0,
  741. CapturingPhase,
  742. AtTarget,
  743. BubblingPhase
  744. Event* {.importc.} = ref object of RootObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Event>`_
  745. bubbles*: bool
  746. cancelBubble*: bool
  747. cancelable*: bool
  748. composed*: bool
  749. currentTarget*: Node
  750. defaultPrevented*: bool
  751. eventPhase*: int
  752. target*: Node
  753. `type`*: cstring
  754. isTrusted*: bool
  755. UIEvent* {.importc.} = ref object of Event ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/UIEvent>`_
  756. detail*: int64
  757. view*: Window
  758. KeyboardEvent* {.importc.} = ref object of UIEvent ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent>`_
  759. altKey*, ctrlKey*, metaKey*, shiftKey*: bool
  760. code*: cstring
  761. isComposing*: bool
  762. key*: cstring
  763. keyCode*: int
  764. location*: int
  765. KeyboardEventKey* {.pure.} = enum ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values>`_
  766. # Modifier keys
  767. Alt,
  768. AltGraph,
  769. CapsLock,
  770. Control,
  771. Fn,
  772. FnLock,
  773. Hyper,
  774. Meta,
  775. NumLock,
  776. ScrollLock,
  777. Shift,
  778. Super,
  779. Symbol,
  780. SymbolLock,
  781. # Whitespace keys
  782. ArrowDown,
  783. ArrowLeft,
  784. ArrowRight,
  785. ArrowUp,
  786. End,
  787. Home,
  788. PageDown,
  789. PageUp,
  790. # Editing keys
  791. Backspace,
  792. Clear,
  793. Copy,
  794. CrSel,
  795. Cut,
  796. Delete,
  797. EraseEof,
  798. ExSel,
  799. Insert,
  800. Paste,
  801. Redo,
  802. Undo,
  803. # UI keys
  804. Accept,
  805. Again,
  806. Attn,
  807. Cancel,
  808. ContextMenu,
  809. Escape,
  810. Execute,
  811. Find,
  812. Finish,
  813. Help,
  814. Pause,
  815. Play,
  816. Props,
  817. Select,
  818. ZoomIn,
  819. ZoomOut,
  820. # Device keys
  821. BrigtnessDown,
  822. BrigtnessUp,
  823. Eject,
  824. LogOff,
  825. Power,
  826. PowerOff,
  827. PrintScreen,
  828. Hibernate,
  829. Standby,
  830. WakeUp,
  831. # Common IME keys
  832. AllCandidates,
  833. Alphanumeric,
  834. CodeInput,
  835. Compose,
  836. Convert,
  837. Dead,
  838. FinalMode,
  839. GroupFirst,
  840. GroupLast,
  841. GroupNext,
  842. GroupPrevious,
  843. ModeChange,
  844. NextCandidate,
  845. NonConvert,
  846. PreviousCandidate,
  847. Process,
  848. SingleCandidate,
  849. # Korean keyboards only
  850. HangulMode,
  851. HanjaMode,
  852. JunjaMode,
  853. # Japanese keyboards only
  854. Eisu,
  855. Hankaku,
  856. Hiragana,
  857. HiraganaKatakana,
  858. KanaMode,
  859. KanjiMode,
  860. Katakana,
  861. Romaji,
  862. Zenkaku,
  863. ZenkakuHanaku,
  864. # Function keys
  865. F1,
  866. F2,
  867. F3,
  868. F4,
  869. F5,
  870. F6,
  871. F7,
  872. F8,
  873. F9,
  874. F10,
  875. F11,
  876. F12,
  877. F13,
  878. F14,
  879. F15,
  880. F16,
  881. F17,
  882. F18,
  883. F19,
  884. F20,
  885. Soft1,
  886. Soft2,
  887. Soft3,
  888. Soft4,
  889. # Phone keys
  890. AppSwitch,
  891. Call,
  892. Camera,
  893. CameraFocus,
  894. EndCall,
  895. GoBack,
  896. GoHome,
  897. HeadsetHook,
  898. LastNumberRedial,
  899. Notification,
  900. MannerMode,
  901. VoiceDial,
  902. # Multimedia keys
  903. ChannelDown,
  904. ChannelUp,
  905. MediaFastForward,
  906. MediaPause,
  907. MediaPlay,
  908. MediaPlayPause,
  909. MediaRecord,
  910. MediaRewind,
  911. MediaStop,
  912. MediaTrackNext,
  913. MediaTrackPrevious,
  914. # Audio control keys
  915. AudioBalanceLeft,
  916. AudioBalanceRight,
  917. AudioBassDown,
  918. AudioBassBoostDown,
  919. AudioBassBoostToggle,
  920. AudioBassBoostUp,
  921. AudioBassUp,
  922. AudioFaderFront,
  923. AudioFaderRear,
  924. AudioSurroundModeNext,
  925. AudioTrebleDown,
  926. AudioTrebleUp,
  927. AudioVolumeDown,
  928. AUdioVolumeMute,
  929. AudioVolumeUp,
  930. MicrophoneToggle,
  931. MicrophoneVolumeDown,
  932. MicrophoneVolumeMute,
  933. MicrophoneVolumeUp,
  934. # TV control keys
  935. TV,
  936. TV3DMode,
  937. TVAntennaCable,
  938. TVAudioDescription,
  939. TVAudioDescriptionMixDown,
  940. TVAudioDescriptionMixUp,
  941. TVContentsMenu,
  942. TVDataService,
  943. TVInput,
  944. TVInputComponent1,
  945. TVInputComponent2,
  946. TVInputComposite1,
  947. TVInputComposite2,
  948. TVInputHDMI1,
  949. TVInputHDMI2,
  950. TVInputHDMI3,
  951. TVInputHDMI4,
  952. TVInputVGA1,
  953. TVMediaContext,
  954. TVNetwork,
  955. TVNumberEntry,
  956. TVPower,
  957. TVRadioService,
  958. TVSatellite,
  959. TVSatelliteBS,
  960. TVSatelliteCS,
  961. TVSatelliteToggle,
  962. TVTerrestrialAnalog,
  963. TVTerrestrialDigital,
  964. TVTimer,
  965. # Media controller keys
  966. AVRInput,
  967. AVRPower,
  968. ColorF0Red,
  969. ColorF1Green,
  970. ColorF2Yellow,
  971. ColorF3Blue,
  972. ColorF4Grey,
  973. ColorF5Brown,
  974. ClosedCaptionToggle,
  975. Dimmer,
  976. DisplaySwap,
  977. DVR,
  978. Exit,
  979. FavoriteClear0,
  980. FavoriteClear1,
  981. FavoriteClear2,
  982. FavoriteClear3,
  983. FavoriteRecall0,
  984. FavoriteRecall1,
  985. FavoriteRecall2,
  986. FavoriteRecall3,
  987. FavoriteStore0,
  988. FavoriteStore1,
  989. FavoriteStore2,
  990. FavoriteStore3,
  991. Guide,
  992. GuideNextDay,
  993. GuidePreviousDay,
  994. Info,
  995. InstantReplay,
  996. Link,
  997. ListProgram,
  998. LiveContent,
  999. Lock,
  1000. MediaApps,
  1001. MediaAudioTrack,
  1002. MediaLast,
  1003. MediaSkipBackward,
  1004. MediaSkipForward,
  1005. MediaStepBackward,
  1006. MediaStepForward,
  1007. MediaTopMenu,
  1008. NavigateIn,
  1009. NavigateNext,
  1010. NavigateOut,
  1011. NavigatePrevious,
  1012. NextFavoriteChannel,
  1013. NextUserProfile,
  1014. OnDemand,
  1015. Pairing,
  1016. PinPDown,
  1017. PinPMove,
  1018. PinPUp,
  1019. PlaySpeedDown,
  1020. PlaySpeedReset,
  1021. PlaySpeedUp,
  1022. RandomToggle,
  1023. RcLowBattery,
  1024. RecordSpeedNext,
  1025. RfBypass,
  1026. ScanChannelsToggle,
  1027. ScreenModeNext,
  1028. Settings,
  1029. SplitScreenToggle,
  1030. STBInput,
  1031. STBPower,
  1032. Subtitle,
  1033. Teletext,
  1034. VideoModeNext,
  1035. Wink,
  1036. ZoomToggle,
  1037. # Speech recognition keys
  1038. SpeechCorrectionList,
  1039. SpeechInputToggle,
  1040. # Document keys
  1041. Close,
  1042. New,
  1043. Open,
  1044. Print,
  1045. Save,
  1046. SpellCheck,
  1047. MailForward,
  1048. MailReply,
  1049. MailSend,
  1050. # Application selector keys
  1051. LaunchCalculator,
  1052. LaunchCalendar,
  1053. LaunchContacts,
  1054. LaunchMail,
  1055. LaunchMediaPlayer,
  1056. LaunchMusicPlayer,
  1057. LaunchMyComputer,
  1058. LaunchPhone,
  1059. LaunchScreenSaver,
  1060. LaunchSpreadsheet,
  1061. LaunchWebBrowser,
  1062. LaunchWebCam,
  1063. LaunchWordProcessor,
  1064. LaunchApplication1,
  1065. LaunchApplication2,
  1066. LaunchApplication3,
  1067. LaunchApplication4,
  1068. LaunchApplication5,
  1069. LaunchApplication6,
  1070. LaunchApplication7,
  1071. LaunchApplication8,
  1072. LaunchApplication9,
  1073. LaunchApplication10,
  1074. LaunchApplication11,
  1075. LaunchApplication12,
  1076. LaunchApplication13,
  1077. LaunchApplication14,
  1078. LaunchApplication15,
  1079. LaunchApplication16,
  1080. # Browser control keys
  1081. BrowserBack,
  1082. BrowserFavorites,
  1083. BrowserForward,
  1084. BrowserHome,
  1085. BrowserRefresh,
  1086. BrowserSearch,
  1087. BrowserStop,
  1088. # Numeric keypad keys
  1089. Key11,
  1090. Key12,
  1091. Separator
  1092. MouseButtons* = enum
  1093. NoButton = 0,
  1094. PrimaryButton = 1,
  1095. SecondaryButton = 2,
  1096. AuxilaryButton = 4,
  1097. FourthButton = 8,
  1098. FifthButton = 16
  1099. MouseEvent* {.importc.} = ref object of UIEvent ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent>`_
  1100. altKey*, ctrlKey*, metaKey*, shiftKey*: bool
  1101. button*: int
  1102. buttons*: int
  1103. clientX*, clientY*: int
  1104. movementX*, movementY*: int
  1105. offsetX*, offsetY*: int
  1106. pageX*, pageY*: int
  1107. relatedTarget*: EventTarget
  1108. #region*: cstring
  1109. screenX*, screenY*: int
  1110. x*, y*: int
  1111. DataTransferItemKind* {.pure.} = enum
  1112. File = "file",
  1113. String = "string"
  1114. DataTransferItem* {.importc.} = ref object of RootObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem>`_
  1115. kind*: cstring
  1116. `type`*: cstring
  1117. DataTransfer* {.importc.} = ref object of RootObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer>`_
  1118. dropEffect*: cstring
  1119. effectAllowed*: cstring
  1120. files*: seq[Element]
  1121. items*: seq[DataTransferItem]
  1122. types*: seq[cstring]
  1123. DataTransferDropEffect* {.pure.} = enum
  1124. None = "none",
  1125. Copy = "copy",
  1126. Link = "link",
  1127. Move = "move"
  1128. DataTransferEffectAllowed* {.pure.} = enum
  1129. None = "none",
  1130. Copy = "copy",
  1131. CopyLink = "copyLink",
  1132. CopyMove = "copyMove",
  1133. Link = "link",
  1134. LinkMove = "linkMove",
  1135. Move = "move",
  1136. All = "all",
  1137. Uninitialized = "uninitialized"
  1138. DragEventTypes* = enum
  1139. Drag = "drag",
  1140. DragEnd = "dragend",
  1141. DragEnter = "dragenter",
  1142. DragExit = "dragexit",
  1143. DragLeave = "dragleave",
  1144. DragOver = "dragover",
  1145. DragStart = "dragstart",
  1146. Drop = "drop"
  1147. DragEvent* {.importc.} = object of MouseEvent
  1148. ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/DragEvent>`_
  1149. dataTransfer*: DataTransfer
  1150. ClipboardEvent* {.importc.} = object of Event
  1151. ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent>`_
  1152. clipboardData*: DataTransfer
  1153. StorageEvent* {.importc.} = ref object of Event ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent>`_
  1154. key*: cstring
  1155. newValue*, oldValue*: cstring
  1156. storageArea*: Storage
  1157. url*: cstring
  1158. TouchList* {.importc.} = ref object of RootObj
  1159. length*: int
  1160. Touch* {.importc.} = ref object of RootObj
  1161. identifier*: int
  1162. screenX*, screenY*, clientX*, clientY*, pageX*, pageY*: int
  1163. target*: Element
  1164. radiusX*, radiusY*: int
  1165. rotationAngle*: int
  1166. force*: float
  1167. TouchEvent* {.importc.} = ref object of UIEvent
  1168. changedTouches*, targetTouches*, touches*: seq[Touch]
  1169. Location* {.importc.} = ref object of RootObj
  1170. hash*: cstring
  1171. host*: cstring
  1172. hostname*: cstring
  1173. href*: cstring
  1174. pathname*: cstring
  1175. port*: cstring
  1176. protocol*: cstring
  1177. search*: cstring
  1178. origin*: cstring
  1179. History* {.importc.} = ref object of RootObj
  1180. length*: int
  1181. Navigator* {.importc.} = ref object of RootObj
  1182. appCodeName*: cstring
  1183. appName*: cstring
  1184. appVersion*: cstring
  1185. buildID*: cstring ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/buildID
  1186. cookieEnabled*: bool
  1187. deviceMemory*: float ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/deviceMemory
  1188. doNotTrack*: cstring ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/doNotTrack
  1189. language*: cstring
  1190. languages*: seq[cstring] ## https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/languages
  1191. maxTouchPoints*: cint ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/maxTouchPoints
  1192. onLine*: bool ## https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine
  1193. oscpu*: cstring ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/oscpu
  1194. platform*: cstring
  1195. userAgent*: cstring
  1196. vendor*: cstring ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vendor
  1197. webdriver*: bool ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/webdriver
  1198. mimeTypes*: seq[ref MimeType]
  1199. Plugin* {.importc.} = object of RootObj
  1200. description*: cstring
  1201. filename*: cstring
  1202. name*: cstring
  1203. MimeType* {.importc.} = object of RootObj
  1204. description*: cstring
  1205. enabledPlugin*: ref Plugin
  1206. suffixes*: seq[cstring]
  1207. `type`*: cstring
  1208. LocationBar* {.importc.} = object of RootObj
  1209. visible*: bool
  1210. MenuBar* = LocationBar
  1211. PersonalBar* = LocationBar
  1212. ScrollBars* = LocationBar
  1213. ToolBar* = LocationBar
  1214. StatusBar* = LocationBar
  1215. Screen* {.importc.} = ref object of RootObj
  1216. availHeight*: int
  1217. availWidth*: int
  1218. colorDepth*: int
  1219. height*: int
  1220. pixelDepth*: int
  1221. width*: int
  1222. TimeOut* {.importc.} = ref object of RootObj
  1223. Interval* {.importc.} = ref object of RootObj
  1224. AddEventListenerOptions* = object
  1225. capture*: bool
  1226. once*: bool
  1227. passive*: bool
  1228. FontFaceSetReady* {.importc.} = ref object
  1229. ## see: `docs<https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/ready>`_
  1230. then*: proc(cb: proc())
  1231. FontFaceSet* {.importc.} = ref object
  1232. ## see: `docs<https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet>`_
  1233. ready*: FontFaceSetReady
  1234. onloadingdone*: proc(event: Event)
  1235. ScrollIntoViewOptions* = object
  1236. behavior*: cstring
  1237. `block`*: cstring
  1238. inline*: cstring
  1239. MediaQueryList* {.importc.} = ref object of EventTarget
  1240. matches*: bool
  1241. media*: cstring
  1242. since (1, 3):
  1243. type
  1244. DomParser* = ref object
  1245. ## DOM Parser object (defined on browser only, may not be on NodeJS).
  1246. ## * https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
  1247. ##
  1248. ## ```nim
  1249. ## let prsr = newDomParser()
  1250. ## discard prsr.parseFromString("<html><marquee>Hello World</marquee></html>".cstring, "text/html".cstring)
  1251. ## ```
  1252. DomException* {.importc.} = ref object
  1253. ## The DOMException interface represents an abnormal event (called an exception)
  1254. ## which occurs as a result of calling a method or accessing a property of a web API.
  1255. ## Each exception has a name, which is a short "CamelCase" style string identifying
  1256. ## the error or abnormal condition.
  1257. ## https://developer.mozilla.org/en-US/docs/Web/API/DOMException
  1258. FileReader* {.importc.} = ref object of EventTarget
  1259. ## The FileReader object lets web applications asynchronously read the contents of files
  1260. ## (or raw data buffers) stored on the user's computer, using File or Blob objects to specify
  1261. ## the file or data to read.
  1262. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader
  1263. FileReaderState* = distinct range[0'u16..2'u16]
  1264. RootNodeOptions* = object of RootObj
  1265. composed*: bool
  1266. DocumentOrShadowRoot* {.importc.} = object of RootObj
  1267. activeElement*: Element
  1268. # styleSheets*: StyleSheetList
  1269. ShadowRoot* {.importc.} = ref object of DocumentOrShadowRoot
  1270. delegatesFocus*: bool
  1271. host*: Element
  1272. innerHTML*: cstring
  1273. mode*: cstring # "open" or "closed"
  1274. ShadowRootInit* = object of RootObj
  1275. mode*: cstring
  1276. delegatesFocus*: bool
  1277. HTMLSlotElement* {.importc.} = ref object of RootObj
  1278. name*: cstring
  1279. SlotOptions* = object of RootObj
  1280. flatten*: bool
  1281. const
  1282. fileReaderEmpty* = 0.FileReaderState
  1283. fileReaderLoading* = 1.FileReaderState
  1284. fileReaderDone* = 2.FileReaderState
  1285. proc id*(n: Node): cstring {.importcpp: "#.id", nodecl.}
  1286. proc `id=`*(n: Node; x: cstring) {.importcpp: "#.id = #", nodecl.}
  1287. proc class*(n: Node): cstring {.importcpp: "#.className", nodecl.}
  1288. proc `class=`*(n: Node; v: cstring) {.importcpp: "#.className = #", nodecl.}
  1289. proc value*(n: Node): cstring {.importcpp: "#.value", nodecl.}
  1290. proc `value=`*(n: Node; v: cstring) {.importcpp: "#.value = #", nodecl.}
  1291. proc checked*(n: Node): bool {.importcpp: "#.checked", nodecl.}
  1292. proc `checked=`*(n: Node; v: bool) {.importcpp: "#.checked = #", nodecl.}
  1293. proc `disabled=`*(n: Node; v: bool) {.importcpp: "#.disabled = #", nodecl.}
  1294. when defined(nodejs):
  1295. # we provide a dummy DOM for nodejs for testing purposes
  1296. proc len*(x: Node): int = x.childNodes.len
  1297. proc `[]`*(x: Node; idx: int): Element =
  1298. assert idx >= 0 and idx < x.childNodes.len
  1299. result = cast[Element](x.childNodes[idx])
  1300. var document* = Document(nodeType: DocumentNode)
  1301. document.ownerDocument = document
  1302. proc getElem(x: Element; id: cstring): Element =
  1303. if x.id == id: return x
  1304. for i in 0..<x.len:
  1305. result = getElem(x[i], id)
  1306. if result != nil: return result
  1307. proc getElementById*(doc: Document; id: cstring): Element =
  1308. getElem(doc.body, id)
  1309. proc getElementById*(id: cstring): Element = document.getElementById(id)
  1310. proc appendChild*(parent, n: Node) =
  1311. n.parentNode = parent
  1312. n.ownerDocument = parent.ownerDocument
  1313. parent.childNodes.add n
  1314. proc replaceChild*(parent, newNode, oldNode: Node) =
  1315. newNode.parentNode = parent
  1316. oldNode.parentNode = nil
  1317. var i = 0
  1318. while i < parent.len:
  1319. if Node(parent[i]) == oldNode:
  1320. parent.childNodes[i] = newNode
  1321. return
  1322. inc i
  1323. raiseAssert "old node not in node list"
  1324. proc removeChild*(parent, child: Node) =
  1325. child.parentNode = nil
  1326. var i = 0
  1327. while i < parent.len:
  1328. if Node(parent[i]) == child:
  1329. parent.childNodes.delete(i)
  1330. return
  1331. inc i
  1332. raiseAssert "old node not in node list"
  1333. proc insertBefore*(parent, newNode, before: Node) =
  1334. appendChild(parent, newNode)
  1335. var i = 0
  1336. while i < parent.len-1:
  1337. if Node(parent[i]) == before:
  1338. for j in countdown(parent.len-1, i-1):
  1339. parent.childNodes[j] = parent.childNodes[j-1]
  1340. parent.childNodes[i-1] = newNode
  1341. return
  1342. inc i
  1343. #raiseAssert "before not in node list"
  1344. proc createElement*(d: Document, identifier: cstring): Element =
  1345. new(result)
  1346. result.nodeName = identifier
  1347. result.nodeType = NodeType.ElementNode
  1348. proc createTextNode*(d: Document, identifier: cstring): Node =
  1349. new(result)
  1350. result.nodeName = "#text"
  1351. result.nodeValue = identifier
  1352. result.nodeType = NodeType.TextNode
  1353. proc createComment*(d: Document, data: cstring): Node =
  1354. new(result)
  1355. result.nodeName = "#comment"
  1356. result.nodeValue = data
  1357. result.nodeType = NodeType.CommentNode
  1358. else:
  1359. proc len*(x: Node): int {.importcpp: "#.childNodes.length".}
  1360. proc `[]`*(x: Node; idx: int): Element {.importcpp: "#.childNodes[#]".}
  1361. proc getElementById*(id: cstring): Element {.importc: "document.getElementById", nodecl.}
  1362. proc appendChild*(n, child: Node) {.importcpp.}
  1363. proc removeChild*(n, child: Node) {.importcpp.}
  1364. proc remove*(child: Node) {.importcpp.}
  1365. proc replaceChild*(n, newNode, oldNode: Node) {.importcpp.}
  1366. proc insertBefore*(n, newNode, before: Node) {.importcpp.}
  1367. proc getElementById*(d: Document, id: cstring): Element {.importcpp.}
  1368. proc createElement*(d: Document, identifier: cstring): Element {.importcpp.}
  1369. proc createElementNS*(d: Document, namespaceURI, qualifiedIdentifier: cstring): Element {.importcpp.}
  1370. proc createTextNode*(d: Document, identifier: cstring): Node {.importcpp.}
  1371. proc createComment*(d: Document, data: cstring): Node {.importcpp.}
  1372. proc setTimeout*(action: proc(); ms: int): TimeOut {.importc, nodecl.}
  1373. proc clearTimeout*(t: TimeOut) {.importc, nodecl.}
  1374. proc setInterval*(action: proc(); ms: int): Interval {.importc, nodecl.}
  1375. proc clearInterval*(i: Interval) {.importc, nodecl.}
  1376. {.push importcpp.}
  1377. # EventTarget "methods"
  1378. proc addEventListener*(et: EventTarget, ev: cstring, cb: proc(ev: Event), useCapture: bool = false)
  1379. proc addEventListener*(et: EventTarget, ev: cstring, cb: proc(ev: Event), options: AddEventListenerOptions)
  1380. proc dispatchEvent*(et: EventTarget, ev: Event)
  1381. proc removeEventListener*(et: EventTarget; ev: cstring; cb: proc(ev: Event))
  1382. # Window "methods"
  1383. proc alert*(w: Window, msg: cstring)
  1384. proc back*(w: Window)
  1385. proc blur*(w: Window)
  1386. proc clearInterval*(w: Window, interval: Interval)
  1387. proc clearTimeout*(w: Window, timeout: TimeOut)
  1388. proc close*(w: Window)
  1389. proc confirm*(w: Window, msg: cstring): bool
  1390. proc disableExternalCapture*(w: Window)
  1391. proc enableExternalCapture*(w: Window)
  1392. proc find*(w: Window, text: cstring, caseSensitive = false,
  1393. backwards = false): bool
  1394. proc focus*(w: Window)
  1395. proc forward*(w: Window)
  1396. proc getComputedStyle*(w: Window, e: Node, pe: Node = nil): Style
  1397. ## .. warning:: The returned Style may or may not be read-only at run-time in the browser. getComputedStyle is performance costly.
  1398. proc handleEvent*(w: Window, e: Event)
  1399. proc home*(w: Window)
  1400. proc moveBy*(w: Window, x, y: int)
  1401. proc moveTo*(w: Window, x, y: int)
  1402. proc open*(w: Window, uri, windowname: cstring,
  1403. properties: cstring = nil): Window
  1404. proc print*(w: Window)
  1405. proc prompt*(w: Window, text, default: cstring): cstring
  1406. proc resizeBy*(w: Window, x, y: int)
  1407. proc resizeTo*(w: Window, x, y: int)
  1408. proc routeEvent*(w: Window, event: Event)
  1409. proc scrollBy*(w: Window, x, y: int)
  1410. proc scrollTo*(w: Window, x, y: int)
  1411. proc setInterval*(w: Window, code: cstring, pause: int): Interval
  1412. proc setInterval*(w: Window, function: proc (), pause: int): Interval
  1413. proc setTimeout*(w: Window, code: cstring, pause: int): TimeOut
  1414. proc setTimeout*(w: Window, function: proc (), pause: int): Interval
  1415. proc stop*(w: Window)
  1416. proc requestAnimationFrame*(w: Window, function: proc (time: float)): int
  1417. proc cancelAnimationFrame*(w: Window, id: int)
  1418. proc matchMedia*(w: Window, mediaQueryString: cstring): MediaQueryList
  1419. # Node "methods"
  1420. proc appendData*(n: Node, data: cstring)
  1421. proc cloneNode*(n: Node, copyContent: bool): Node
  1422. proc deleteData*(n: Node, start, len: int)
  1423. proc focus*(e: Node)
  1424. proc getAttribute*(n: Node, attr: cstring): cstring
  1425. proc getAttributeNode*(n: Node, attr: cstring): Node
  1426. proc hasAttribute*(n: Node, attr: cstring): bool
  1427. proc hasChildNodes*(n: Node): bool
  1428. proc normalize*(n: Node)
  1429. proc insertData*(n: Node, position: int, data: cstring)
  1430. proc removeAttribute*(n: Node, attr: cstring)
  1431. proc removeAttributeNode*(n, attr: Node)
  1432. proc replaceData*(n: Node, start, len: int, text: cstring)
  1433. proc scrollIntoView*(n: Node)
  1434. proc scrollIntoView*(n: Node, options: ScrollIntoViewOptions)
  1435. proc setAttribute*(n: Node, name, value: cstring)
  1436. proc setAttributeNode*(n: Node, attr: Node)
  1437. proc querySelector*(n: Node, selectors: cstring): Element
  1438. proc querySelectorAll*(n: Node, selectors: cstring): seq[Element]
  1439. proc compareDocumentPosition*(n: Node, otherNode:Node): int
  1440. proc lookupPrefix*(n: Node): cstring
  1441. proc lookupNamespaceURI*(n: Node): cstring
  1442. proc isDefaultNamespace*(n: Node): bool
  1443. proc contains*(n: Node): bool
  1444. proc isEqualNode*(n: Node): bool
  1445. proc isSameNode*(n: Node): bool
  1446. since (1, 3):
  1447. proc getRootNode*(n: Node,options: RootNodeOptions): Node
  1448. # DocumentOrShadowRoot
  1449. proc getSelection*(n: DocumentOrShadowRoot): Selection
  1450. proc elementFromPoint*(n: DocumentOrShadowRoot; x, y: float): Element
  1451. # shadow dom
  1452. proc attachShadow*(n: Element): ShadowRoot
  1453. proc assignedNodes*(n: HTMLSlotElement; options: SlotOptions): seq[Node]
  1454. proc assignedElements*(n: HTMLSlotElement; options: SlotOptions): seq[Element]
  1455. # Document "methods"
  1456. proc createAttribute*(d: Document, identifier: cstring): Node
  1457. proc getElementsByName*(d: Document, name: cstring): seq[Element]
  1458. proc getElementsByTagName*(d: Document, name: cstring): seq[Element]
  1459. proc getElementsByClassName*(d: Document, name: cstring): seq[Element]
  1460. proc insertNode*(range: Range, node: Node)
  1461. proc getSelection*(d: Document): Selection
  1462. proc handleEvent*(d: Document, event: Event)
  1463. proc open*(d: Document)
  1464. proc routeEvent*(d: Document, event: Event)
  1465. proc write*(d: Document, text: cstring)
  1466. proc writeln*(d: Document, text: cstring)
  1467. proc querySelector*(d: Document, selectors: cstring): Element
  1468. proc querySelectorAll*(d: Document, selectors: cstring): seq[Element]
  1469. # Element "methods"
  1470. proc blur*(e: Element)
  1471. proc click*(e: Element)
  1472. proc focus*(e: Element)
  1473. proc handleEvent*(e: Element, event: Event)
  1474. proc select*(e: Element)
  1475. proc getElementsByTagName*(e: Element, name: cstring): seq[Element]
  1476. proc getElementsByClassName*(e: Element, name: cstring): seq[Element]
  1477. # FormElement "methods"
  1478. proc reset*(f: FormElement)
  1479. proc submit*(f: FormElement)
  1480. proc checkValidity*(e: FormElement): bool
  1481. proc reportValidity*(e: FormElement): bool
  1482. # EmbedElement "methods"
  1483. proc play*(e: EmbedElement)
  1484. proc stop*(e: EmbedElement)
  1485. # Location "methods"
  1486. proc reload*(loc: Location)
  1487. proc replace*(loc: Location, s: cstring)
  1488. # History "methods"
  1489. proc back*(h: History)
  1490. proc forward*(h: History)
  1491. proc go*(h: History, pagesToJump: int)
  1492. proc pushState*[T](h: History, stateObject: T, title, url: cstring)
  1493. # Navigator "methods"
  1494. proc javaEnabled*(h: Navigator): bool
  1495. since (1, 3):
  1496. proc canShare*(self: Navigator; data: cstring): bool ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/canShare
  1497. proc sendBeacon*(self: Navigator; url, data: cstring): bool ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
  1498. proc vibrate*(self: Navigator; pattern: cint): bool ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate
  1499. proc vibrate*(self: Navigator; pattern: openArray[cint]): bool ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate
  1500. proc registerProtocolHandler*(self: Navigator; scheme, url, title: cstring) ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler
  1501. # ClassList "methods"
  1502. proc add*(c: ClassList, class: cstring)
  1503. proc remove*(c: ClassList, class: cstring)
  1504. proc contains*(c: ClassList, class: cstring): bool
  1505. proc toggle*(c: ClassList, class: cstring)
  1506. # Style "methods"
  1507. proc getPropertyValue*(s: Style, property: cstring): cstring
  1508. proc removeProperty*(s: Style, property: cstring)
  1509. proc setProperty*(s: Style, property, value: cstring, priority = "")
  1510. proc getPropertyPriority*(s: Style, property: cstring): cstring
  1511. # Event "methods"
  1512. proc preventDefault*(ev: Event)
  1513. proc stopImmediatePropagation*(ev: Event)
  1514. proc stopPropagation*(ev: Event)
  1515. # KeyboardEvent "methods"
  1516. proc getModifierState*(ev: KeyboardEvent, keyArg: cstring): bool
  1517. # MouseEvent "methods"
  1518. proc getModifierState*(ev: MouseEvent, keyArg: cstring): bool
  1519. # TouchEvent "methods"
  1520. proc identifiedTouch*(list: TouchList): Touch
  1521. proc item*(list: TouchList, i: int): Touch
  1522. # DataTransfer "methods"
  1523. proc clearData*(dt: DataTransfer, format: cstring)
  1524. proc getData*(dt: DataTransfer, format: cstring): cstring
  1525. proc setData*(dt: DataTransfer, format: cstring, data: cstring)
  1526. proc setDragImage*(dt: DataTransfer, img: Element, xOffset: int, yOffset: int)
  1527. # DataTransferItem "methods"
  1528. proc getAsFile*(dti: DataTransferItem): File
  1529. # InputElement "methods"
  1530. proc setSelectionRange*(e: InputElement, selectionStart: int, selectionEnd: int, selectionDirection: cstring = "none")
  1531. proc setRangeText*(e: InputElement, replacement: cstring, startindex: int = 0, endindex: int = 0, selectionMode: cstring = "preserve")
  1532. proc setCustomValidity*(e: InputElement, error: cstring)
  1533. proc checkValidity*(e: InputElement): bool
  1534. # Blob "methods"
  1535. proc slice*(e: Blob, startindex: int = 0, endindex: int = e.size, contentType: cstring = "")
  1536. # Performance "methods"
  1537. proc now*(p: Performance): float
  1538. # Selection "methods"
  1539. proc removeAllRanges*(s: Selection)
  1540. proc deleteFromDocument*(s: Selection)
  1541. proc getRangeAt*(s: Selection, index: int): Range
  1542. converter toString*(s: Selection): cstring
  1543. proc `$`*(s: Selection): string = $(s.toString())
  1544. # Storage "methods"
  1545. proc getItem*(s: Storage, key: cstring): cstring
  1546. proc setItem*(s: Storage, key, value: cstring)
  1547. proc clear*(s: Storage)
  1548. proc removeItem*(s: Storage, key: cstring)
  1549. {.pop.}
  1550. proc setAttr*(n: Node; key, val: cstring) {.importcpp: "#.setAttribute(@)".}
  1551. var
  1552. window* {.importc, nodecl.}: Window
  1553. navigator* {.importc, nodecl.}: Navigator
  1554. screen* {.importc, nodecl.}: Screen
  1555. when not defined(nodejs):
  1556. var document* {.importc, nodecl.}: Document
  1557. proc decodeURI*(uri: cstring): cstring {.importc, nodecl.}
  1558. proc encodeURI*(uri: cstring): cstring {.importc, nodecl.}
  1559. proc escape*(uri: cstring): cstring {.importc, nodecl.}
  1560. proc unescape*(uri: cstring): cstring {.importc, nodecl.}
  1561. proc decodeURIComponent*(uri: cstring): cstring {.importc, nodecl.}
  1562. proc encodeURIComponent*(uri: cstring): cstring {.importc, nodecl.}
  1563. proc isFinite*(x: BiggestFloat): bool {.importc, nodecl.}
  1564. proc isNaN*(x: BiggestFloat): bool {.importc, nodecl.}
  1565. ## see also `math.isNaN`.
  1566. proc newEvent*(name: cstring): Event {.importcpp: "new Event(@)", constructor.}
  1567. proc getElementsByClass*(n: Node; name: cstring): seq[Node] {.
  1568. importcpp: "#.getElementsByClassName(#)", nodecl.}
  1569. type
  1570. BoundingRect* {.importc.} = object
  1571. top*, bottom*, left*, right*, x*, y*, width*, height*: float
  1572. proc getBoundingClientRect*(e: Node): BoundingRect {.
  1573. importcpp: "getBoundingClientRect", nodecl.}
  1574. proc clientHeight*(): int {.
  1575. importcpp: "(window.innerHeight || document.documentElement.clientHeight)@", nodecl.}
  1576. proc clientWidth*(): int {.
  1577. importcpp: "(window.innerWidth || document.documentElement.clientWidth)@", nodecl.}
  1578. proc inViewport*(el: Node): bool =
  1579. let rect = el.getBoundingClientRect()
  1580. result = rect.top >= 0 and rect.left >= 0 and
  1581. rect.bottom <= clientHeight().float and
  1582. rect.right <= clientWidth().float
  1583. proc scrollTop*(e: Node): int {.importcpp: "#.scrollTop", nodecl.}
  1584. proc `scrollTop=`*(e: Node, value: int) {.importcpp: "#.scrollTop = #", nodecl.}
  1585. proc scrollLeft*(e: Node): int {.importcpp: "#.scrollLeft", nodecl.}
  1586. proc scrollHeight*(e: Node): int {.importcpp: "#.scrollHeight", nodecl.}
  1587. proc scrollWidth*(e: Node): int {.importcpp: "#.scrollWidth", nodecl.}
  1588. proc offsetHeight*(e: Node): int {.importcpp: "#.offsetHeight", nodecl.}
  1589. proc offsetWidth*(e: Node): int {.importcpp: "#.offsetWidth", nodecl.}
  1590. proc offsetTop*(e: Node): int {.importcpp: "#.offsetTop", nodecl.}
  1591. proc offsetLeft*(e: Node): int {.importcpp: "#.offsetLeft", nodecl.}
  1592. since (1, 3):
  1593. func newDomParser*(): DomParser {.importcpp: "new DOMParser()".}
  1594. ## DOM Parser constructor.
  1595. func parseFromString*(this: DomParser; str: cstring; mimeType: cstring): Document {.importcpp.}
  1596. ## Parse from string to `Document`.
  1597. proc newDomException*(): DomException {.importcpp: "new DomException()", constructor.}
  1598. ## DOM Exception constructor
  1599. proc message*(ex: DomException): cstring {.importcpp: "#.message", nodecl.}
  1600. ## https://developer.mozilla.org/en-US/docs/Web/API/DOMException/message
  1601. proc name*(ex: DomException): cstring {.importcpp: "#.name", nodecl.}
  1602. ## https://developer.mozilla.org/en-US/docs/Web/API/DOMException/name
  1603. proc newFileReader*(): FileReader {.importcpp: "new FileReader()", constructor.}
  1604. ## File Reader constructor
  1605. proc error*(f: FileReader): DomException {.importcpp: "#.error", nodecl.}
  1606. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/error
  1607. proc readyState*(f: FileReader): FileReaderState {.importcpp: "#.readyState", nodecl.}
  1608. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readyState
  1609. proc resultAsString*(f: FileReader): cstring {.importcpp: "#.result", nodecl.}
  1610. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result
  1611. proc abort*(f: FileReader) {.importcpp: "#.abort()".}
  1612. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/abort
  1613. proc readAsBinaryString*(f: FileReader, b: Blob) {.importcpp: "#.readAsBinaryString(#)".}
  1614. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsBinaryString
  1615. proc readAsDataURL*(f: FileReader, b: Blob) {.importcpp: "#.readAsDataURL(#)".}
  1616. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL
  1617. proc readAsText*(f: FileReader, b: Blob|File, encoding = cstring"UTF-8") {.importcpp: "#.readAsText(#, #)".}
  1618. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsText
  1619. since (1, 5):
  1620. proc elementsFromPoint*(n: DocumentOrShadowRoot; x, y: float): seq[Element] {.importcpp.}
  1621. since (1, 7):
  1622. proc insertAdjacentText*(self: Node; position, data: cstring) {.importjs: "#.$1(#, #)".}
  1623. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentText
  1624. proc insertAdjacentElement*(self: Node; position: cstring; element: Node) {.importjs: "#.$1(#, #)".}
  1625. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentElement
  1626. proc insertAdjacentHTML*(self: Node; position, html: cstring) {.importjs: "#.$1(#, #)".}
  1627. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML
  1628. proc after*(self: Node; element: Node): Node {.importjs: "#.$1(@)", varargs.}
  1629. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/after
  1630. proc before*(self: Node; element: Node): Node {.importjs: "#.$1(@)", varargs.}
  1631. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/before
  1632. proc append*(self: Node; element: Node): Node {.importjs: "#.$1(@)", varargs.}
  1633. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/append
  1634. proc closest*(self: Node; cssSelector: cstring): Node {.importjs: "#.$1(#)".}
  1635. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
  1636. proc hasAttributeNS*(self: Node; namespace, localName: cstring): bool {.importjs: "(#.$1(#, #) || false)".}
  1637. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttributeNS
  1638. proc removeAttributeNS*(self: Node; namespace, attributeName: cstring) {.importjs: "#.$1(#, #)".}
  1639. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttributeNS
  1640. proc hasPointerCapture*(self: Node; pointerId: SomeNumber): bool {.importjs: "(#.$1(#) || false)".}
  1641. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/hasPointerCapture
  1642. proc releasePointerCapture*(self: Node; pointerId: SomeNumber) {.importjs: "#.$1(#)".}
  1643. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/releasePointerCapture
  1644. proc requestPointerLock*(self: Node) {.importjs: "#.$1()".}
  1645. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/requestPointerLock
  1646. proc replaceChildren*(self: Node; replacements: Node) {.importjs: "#.$1(@)", varargs.}
  1647. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren
  1648. proc replaceWith*(self: Node; replacements: Node) {.importjs: "#.$1(@)", varargs.}
  1649. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceWith
  1650. proc scrollIntoViewIfNeeded*(self: Node; centerIfNeeded: bool) {.importjs: "#.$1(#)".}
  1651. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded
  1652. proc setHTML*(self: Node; html: cstring) {.importjs: "#.$1(#)".}
  1653. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/setHTML
  1654. proc toggleAttribute*(self: Node; name: cstring; force = false): bool {.importjs: "(#.$1(#, #) || false)".}
  1655. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/toggleAttribute
  1656. proc matches*(self: Node; cssSelector: cstring): bool {.importjs: "(#.$1(#) || false)".}
  1657. ## https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
  1658. since (2, 1):
  1659. type VisualViewport* {.importc.} = ref object of EventTarget
  1660. offsetLeft*, offsetTop*, pageLeft*, pageTop*, width*, height*, scale*: float
  1661. onResize*, onScroll*: proc (event: Event) {.closure.}
  1662. func visualViewport*(self: Window): VisualViewport {.importjs: "#.$1", nodecl.}