Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/DOMAPI/Document.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ open DOMTypes
open EventTypes
open ViewTransitionsTypes

type t = document = {...document}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/DOMAPI/Element.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
open DOMTypes
open Prelude

type t = element = {...element}

module Impl = (
T: {
type t
Expand Down
2 changes: 2 additions & 0 deletions src/DOMAPI/HTMLCanvasElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ open DOMTypes
open CanvasTypes
open MediaCaptureAndStreamsTypes

type t = htmlCanvasElement = {...htmlCanvasElement}

include HTMLElement.Impl({type t = htmlCanvasElement})

/**
Expand Down
2 changes: 2 additions & 0 deletions src/DOMAPI/HTMLElement.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open DOMTypes

type t = htmlElement = {...htmlElement}

module Impl = (
T: {
type t
Expand Down
2 changes: 2 additions & 0 deletions src/DOMAPI/HTMLImageElement.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open DOMTypes

type t = htmlImageElement = {...htmlImageElement}

include HTMLElement.Impl({type t = htmlImageElement})

/**
Expand Down
2 changes: 2 additions & 0 deletions src/DOMAPI/HTMLInputElement.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open DOMTypes

type t = htmlInputElement = {...htmlInputElement}

include HTMLElement.Impl({type t = htmlInputElement})

/**
Expand Down
2 changes: 2 additions & 0 deletions src/DOMAPI/Location.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open DOMTypes

type t = location = {...location}

/**
Navigates to the given URL.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/assign)
Expand Down
2 changes: 2 additions & 0 deletions src/DOMAPI/Node.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open DOMTypes

type t = node = {...node}

module Impl = (
T: {
type t
Expand Down
2 changes: 1 addition & 1 deletion src/DOMAPI/Window.res
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ external clearInterval: (window, int) => unit = "clearInterval"
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask)
*/
@send
external queueMicrotask: (window, voidFunction) => unit = "queueMicrotask"
external queueMicrotask: (window, unit => unit) => unit = "queueMicrotask"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap)
Expand Down
2 changes: 2 additions & 0 deletions src/EventAPI/AbortController.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open EventTypes

type t = abortController = {...abortController}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AbortController)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/EventAPI/AbortSignal.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open EventTypes

type t = abortSignal = {...abortSignal}

include EventTarget.Impl({type t = abortSignal})

/**
Expand Down
2 changes: 2 additions & 0 deletions src/EventAPI/Event.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open EventTypes

type t = event = {...event}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Event)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/EventAPI/EventTarget.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open EventTypes

type t = eventTarget = {...eventTarget}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/EventAPI/ExtendableEvent.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open EventTypes

type t = extendableEvent = {...extendableEvent}

module Impl = (
T: {
type t
Expand Down
2 changes: 2 additions & 0 deletions src/IntersectionObserverAPI/IntersectionObserver.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
open DOMTypes
open IntersectionObserverTypes

type t = intersectionObserver = {...intersectionObserver}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IntersectionObserver)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/IntersectionObserverAPI/IntersectionObserverRoot.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
open DOMTypes
open IntersectionObserverTypes

type t = root

external fromDocument: document => root = "%identity"
external fromElement: element => root = "%identity"
external fromNull: root = "null"
Expand Down
2 changes: 2 additions & 0 deletions src/MutationObserverAPI/MutationObserver.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
open DOMTypes
open MutationObserverTypes

type t = mutationObserver

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MutationObserver)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/ResizeObserverAPI/ResizeObserver.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
open DOMTypes
open ResizeObserverTypes

type t = resizeObserver = {...resizeObserver}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ResizeObserver)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/CompositionEvent.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open UIEventsTypes

type t = compositionEvent = {...compositionEvent}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CompositionEvent)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/DataTransfer.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
open UIEventsTypes
open DOMTypes

type t = dataTransfer = {...dataTransfer}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DataTransfer)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/DataTransferItem.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ open UIEventsTypes
open FileTypes
open FileAndDirectoryEntriesTypes

type t = dataTransferItem = {...dataTransferItem}

/**
Invokes the callback with the string data as the argument, if the drag data item kind is text.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DataTransferItem/getAsString)
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/DataTransferItemList.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
open UIEventsTypes
open FileTypes

type t = dataTransferItemList = {...dataTransferItemList}

/**
Adds a new entry for the given data to the drag data store. If the data is plain text then a type string has to be provided also.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DataTransferItemList/add)
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/FocusEvent.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open UIEventsTypes

type t = focusEvent = {...focusEvent}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FocusEvent)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/InputEvent.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
open UIEventsTypes
open DOMTypes

type t = inputEvent = {...inputEvent}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/InputEvent)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/KeyboardEvent.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open UIEventsTypes

type t = keyboardEvent = {...keyboardEvent}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/KeyboardEvent)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/MouseEvent.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open UIEventsTypes

type t = mouseEvent = {...mouseEvent}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/PointerEvent.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open UIEventsTypes

type t = pointerEvent = {...pointerEvent}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/PointerEvent)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/Touch.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open UIEventsTypes

type t = touch = {...touch}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Touch)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/TouchEvent.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open UIEventsTypes

type t = touchEvent = {...touchEvent}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/TouchEvent)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/TouchList.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open UIEventsTypes

type t = touchList = {...touchList}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/TouchList/item)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/UIEvent.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open UIEventsTypes

type t = uiEvent = {...uiEvent}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/UIEvent)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/UIEventsAPI/WheelEvent.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open UIEventsTypes

type t = wheelEvent = {...wheelEvent}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/WheelEvent)
*/
Expand Down
2 changes: 2 additions & 0 deletions src/ViewTransitionsAPI/ViewTransition.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open ViewTransitionsTypes

type t = viewTransition = {...viewTransition}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ViewTransition/skipTransition)
*/
Expand Down
8 changes: 3 additions & 5 deletions tests/DOMAPI/AddEventListener__test.res
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
open WebAPI
open WebAPI.Global

let button = document->Document.querySelector("button")->Null.toOption
let h2 = document->Document.querySelector("h2")->Null.toOption
let button = Window.current.document->Document.querySelector("button")->Null.toOption
let h2 = Window.current.document->Document.querySelector("h2")->Null.toOption

switch (button, h2) {
| (Some(button), Some(h2)) =>
button->Element.addEventListener(EventTypes.Click, (e: UIEventsTypes.mouseEvent) => {
button->Element.addEventListener(EventTypes.Click, (e: MouseEvent.t) => {
Console.log(`Button clicked, ${Int.toString(e.button)}`)
switch h2.textContent {
| Null => h2.textContent = Value("1")
Expand Down
2 changes: 1 addition & 1 deletion tests/DOMAPI/Element__test.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
external myElement: DOMTypes.element = "myElement"
external myElement: Element.t = "myElement"

switch myElement->Element.getAttribute("foo") {
| Null.Value(value) => value->Console.log
Expand Down
8 changes: 3 additions & 5 deletions tests/DOMAPI/HTMLCanvasElement__test.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
open WebAPI.Global

let myCanvas: DOMTypes.htmlCanvasElement =
document->Document.getElementById("myCanvas")->Prelude.unsafeConversation
let myCanvas: HTMLCanvasElement.t =
Window.current.document->Document.getElementById("myCanvas")->Prelude.unsafeConversation
let ctx = myCanvas->HTMLCanvasElement.getContext2D

ctx.fillStyle = FillStyle.fromString("red")
Expand All @@ -18,7 +16,7 @@ switch ctx.fillStyle->FillStyle.decode {
| FillStyle.CanvasPattern(_) => Console.log("CanvasPattern")
}

let img: DOMTypes.htmlImageElement = document->Document.createElement("img")->Obj.magic
let img: HTMLImageElement.t = Window.current.document->Document.createElement("img")->Obj.magic
ctx->CanvasRenderingContext2D.drawImageWithDimensions(
~image=img,
~dx=0.,
Expand Down
3 changes: 1 addition & 2 deletions tests/DOMAPI/HTMLElement__test.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
open WebAPI
open WebAPI.Global

document
Window.current.document
->Document.querySelector("form")
->Null.toOption
->Option.forEach(form => {
Expand Down
6 changes: 2 additions & 4 deletions tests/DOMAPI/HTMLInputElement__test.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
open Global

let input: DOMTypes.htmlInputElement =
document->Document.createElement("input")->Prelude.unsafeConversation
let input: HTMLInputElement.t =
Window.current.document->Document.createElement("input")->Prelude.unsafeConversation
let value = input.value
5 changes: 1 addition & 4 deletions tests/DOMAPI/Location__test.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
open Global

// Note that this only works when you added the `-open Global` bsc flag.
let location = window.location
let location = Window.current.location

// Access properties using `.`
let href = location.href
Expand Down
8 changes: 4 additions & 4 deletions tests/IntersectionObserverAPI/IntersectionObserver__test.res
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
let observer = IntersectionObserver.make(~callback=(entry, observer) => {
let observer: IntersectionObserver.t = IntersectionObserver.make(~callback=(entry, observer) => {
Console.log2(entry, observer)
})

let root = Global.document->Document.querySelector("#root")->Null.getUnsafe
let root = Window.current.document->Document.querySelector("#root")->Null.getUnsafe

let observer2 = IntersectionObserver.make(
let observer2: IntersectionObserver.t = IntersectionObserver.make(
~callback=(entry, observer) => {
Console.log2(entry, observer)
},
Expand All @@ -22,7 +22,7 @@ switch observer2.root->IntersectionObserverRoot.decode {
}
let rootMargin2 = observer2.rootMargin

let targetElement = Global.document->Document.querySelector("#targetElement")->Null.toOption
let targetElement = Window.current.document->Document.querySelector("#targetElement")->Null.toOption
switch targetElement {
| Some(e) => {
observer2->IntersectionObserver.observe(e)
Expand Down
6 changes: 3 additions & 3 deletions tests/MutationObserverAPI/MutationObserver__test.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let observer = MutationObserver.make((mutations, obs) => {
let button = Global.document->Document.querySelector("button")
let observer: MutationObserver.t = MutationObserver.make((mutations, obs) => {
let button = Window.current.document->Document.querySelector("button")
switch button->Null.toOption {
| Some(button) => {
Console.log(button)
Expand All @@ -11,7 +11,7 @@ let observer = MutationObserver.make((mutations, obs) => {
})

observer->MutationObserver.observe(
~target=Global.document->Document.asNode,
~target=Window.current.document->Document.asNode,
~options={childList: true, subtree: true},
)

Expand Down