Shadow Dom apis (#14979)

* shadow dom api

* fix typos

* host to Element type

* fix code style

* move elementsFromPoint to dom_extensions.nim
This commit is contained in:
Bung
2020-07-22 01:11:12 +08:00
committed by GitHub
parent c8a72e0748
commit 64d629c617
2 changed files with 37 additions and 0 deletions

View File

@@ -1324,6 +1324,26 @@ since (1, 3):
FileReaderObj {.importc.} = object of EventTargetObj
FileReaderState* = distinct range[0'u16..2'u16]
RootNodeOptions* = object of RootObj
composed*: bool
DocumentOrShadowRoot* {.importc.} = object of RootObj
activeElement*: Element
# styleSheets*: StyleSheetList
ShadowRoot* = ref ShadowRootObj
ShadowRootObj {.importc.} = object of DocumentOrShadowRoot
delegatesFocus*: bool
host*: Element
innerHTML*: cstring
mode*: cstring # "open" or "closed"
ShadowRootInit* = object of RootObj
mode*: cstring
delegatesFocus*: bool
HTMLSlotElement* = ref HTMLSlotElementObj
HTMLSlotElementObj {.importc.} = object of RootObj
name*: cstring
SlotOptions* = object of RootObj
flatten*: bool
const
fileReaderEmpty* = 0.FileReaderState
@@ -1503,6 +1523,18 @@ proc contains*(n: Node): bool
proc isEqualNode*(n: Node): bool
proc isSameNode*(n: Node): bool
since (1, 3):
proc getRootNode*(n: Node,options: RootNodeOptions): Node
# DocumentOrShadowRoot
proc getSelection*(n: DocumentOrShadowRoot): Selection
proc elementFromPoint*(n: DocumentOrShadowRoot; x, y: float): Element
# shadow dom
proc attachShadow*(n: Element): ShadowRoot
proc assignedNodes*(n: HTMLSlotElement; options: SlotOptions): seq[Node]
proc assignedElements*(n: HTMLSlotElement; options: SlotOptions): seq[Element]
# Document "methods"
proc createAttribute*(d: Document, identifier: cstring): Node
proc getElementsByName*(d: Document, name: cstring): seq[Element]

View File

@@ -0,0 +1,5 @@
import dom
{.push importcpp.}
proc elementsFromPoint*(n: DocumentOrShadowRoot; x, y: float): seq[Element]
{.pop.}