Skip to content
Draft
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
22 changes: 10 additions & 12 deletions src/dom-nodes/DOMTree.res
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ type slotAssignmentMode =
| @as("manual") Manual
| @as("named") Named

type customStateSet = {}
type customStateSet = private {}

/**
Node is an interface from which a number of WebApiDOM API object types inherit. It allows those types to be treated similarly; for example, inheriting the same set of methods, or being tested in the same way.
[See Node on MDN](https://developer.mozilla.org/docs/Web/API/Node)
TODO: mark as private once mutating fields of private records is allowed
*/
@editor.completeFrom(Node)
type rec node = {
type rec node = private {
...DOM.eventTarget,
/**
Returns the type of node.
Expand Down Expand Up @@ -91,9 +90,8 @@ type rec node = {
/**
Element is the most general base class from which all objects in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element.
[See Element on MDN](https://developer.mozilla.org/docs/Web/API/Element)
TODO: mark as private once mutating fields of private records is allowed
*/
@editor.completeFrom(Element) and element = {
@editor.completeFrom(Element) and element = private {
// Base properties from Node
/**
Returns the type of node.
Expand Down Expand Up @@ -463,7 +461,7 @@ A minimal document object that has no parent. It is used as a lightweight versio
[See DocumentFragment on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment)
TODO: mark as private once mutating fields of private records is allowed
*/
@editor.completeFrom(DocumentFragment) and documentFragment = {
@editor.completeFrom(DocumentFragment) and documentFragment = private {
// Base properties from Node
/**
Returns the type of node.
Expand Down Expand Up @@ -560,7 +558,7 @@ TODO: mark as private once mutating fields of private records is allowed
[See ShadowRoot on MDN](https://developer.mozilla.org/docs/Web/API/ShadowRoot)
TODO: mark as private once mutating fields of private records is allowed
*/
@editor.completeFrom(ShadowRoot) and shadowRoot = {
@editor.completeFrom(ShadowRoot) and shadowRoot = private {
// Base properties from DocumentFragment
// End base properties from DocumentFragment

Expand Down Expand Up @@ -703,7 +701,7 @@ Any HTML element. Some elements directly implement this interface, while others
[See HTMLElement on MDN](https://developer.mozilla.org/docs/Web/API/HTMLElement)
TODO: mark as private once mutating fields of private records is allowed
*/
@editor.completeFrom(HTMLElement) and htmlElement = {
@editor.completeFrom(HTMLElement) and htmlElement = private {
// Base properties from Element
/**
Returns the namespace.
Expand Down Expand Up @@ -996,7 +994,7 @@ A <form> element in the WebApiDOM; it allows access to and in some cases modific
[See HTMLFormElement on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFormElement)
TODO: mark as private once mutating fields of private records is allowed
*/
@editor.completeFrom(HTMLFormElement) and htmlFormElement = {
@editor.completeFrom(HTMLFormElement) and htmlFormElement = private {
// Base properties from HTMLElement
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLElement/title)
Expand Down Expand Up @@ -1298,12 +1296,12 @@ TODO: mark as private once mutating fields of private records is allowed
}

@editor.completeFrom(HTMLFormControlsCollection)
and htmlFormControlsCollection = {
and htmlFormControlsCollection = private {
length: int,
}

@editor.completeFrom(HTMLSlotElement)
and htmlSlotElement = {
and htmlSlotElement = private {
// Base properties from Element
/**
Returns the namespace.
Expand Down Expand Up @@ -1596,7 +1594,7 @@ and htmlSlotElement = {
}

@editor.completeFrom(ElementInternals)
and elementInternals = {
and elementInternals = private {
shadowRoot: Null.t<shadowRoot>,
form: Null.t<htmlFormElement>,
willValidate: bool,
Expand Down
6 changes: 6 additions & 0 deletions src/dom-nodes/Node.res
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ module Impl = (

external asNode: T.t => DOMTree.node = "%identity"

@set
external setNodeValue: (T.t, Null.t<string>) => unit = "nodeValue"

@set
external setTextContent: (T.t, Null.t<string>) => unit = "textContent"

type getRootNodeOptions = {mutable composed?: bool}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/file/FileTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This Streams API interface represents a readable stream of byte data. The WebApi
[See ReadableStream on MDN](https://developer.mozilla.org/docs/Web/API/ReadableStream)
*/
@editor.completeFrom(ReadableStream)
type readableStream<'r> = {
type readableStream<'r> = private {
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked)
*/
Expand All @@ -49,7 +49,7 @@ This Streams API interface provides a standard abstraction for writing streamin
[See WritableStream on MDN](https://developer.mozilla.org/docs/Web/API/WritableStream)
*/
@editor.completeFrom(WritableStream)
type writableStream<'w> = {
type writableStream<'w> = private {
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/WritableStream/locked)
*/
Expand Down
2 changes: 1 addition & 1 deletion src/file/WritableStream.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@editor.completeFrom(WritableStream)
type t<'w> = FileTypes.writableStream<'w> = {...FileTypes.writableStream<'w>}
type t<'w> = FileTypes.writableStream<'w> = private {...FileTypes.writableStream<'w>}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/WritableStream)
Expand Down
3 changes: 3 additions & 0 deletions src/html/HTMLSlotElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ type t = DOMTree.htmlSlotElement = private {

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

@set
external setName: (t, string) => unit = "name"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSlotElement/assignedNodes)
*/
Expand Down
5 changes: 2 additions & 3 deletions src/messaging/WebSocketsTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ type messageEventSource = unknown
/**
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
[See WebSocket on MDN](https://developer.mozilla.org/docs/Web/API/WebSocket)
TODO: mark as private once mutating fields of private records is allowed
*/
@editor.completeFrom(WebSocket)
type webSocket = {
type webSocket = private {
...DOM.eventTarget,
/**
Returns the WebApiURL that was used to establish the WebSocket connection.
Expand Down Expand Up @@ -47,7 +46,7 @@ If the WebSocket connection is closed, this attribute's value will only increase
Can be set, to change how binary data is returned. The default is "blob".
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType)
*/
mutable binaryType: binaryType,
binaryType: binaryType,
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/storage/IDBIndex.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = IndexedDbTypes.idbIndex = {...IndexedDbTypes.idbIndex}
type t = IndexedDbTypes.idbIndex = private {...IndexedDbTypes.idbIndex}

/**
Retrieves the value of the first record matching the given key or key range in query.
Expand Down
2 changes: 1 addition & 1 deletion src/storage/IDBObjectStore.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = IndexedDbTypes.idbObjectStore = {...IndexedDbTypes.idbObjectStore}
type t = IndexedDbTypes.idbObjectStore = private {...IndexedDbTypes.idbObjectStore}

/**
Adds or updates a record in store with the given value and key.
Expand Down
8 changes: 4 additions & 4 deletions src/storage/IndexedDbTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ type idbOpenDBRequest = {
/**
This example shows a variety of different uses of object stores, from updating the data structure with IDBObjectStore.createIndex inside an onupgradeneeded function, to adding a new item to our object store with IDBObjectStore.add. For a full working example, see our To-do Notifications app (view example live.)
[See IDBObjectStore on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore)
TODO: mark as private once mutating fields of private records is allowed
*/
@editor.completeFrom(IDBObjectStore)
type idbObjectStore = {
type idbObjectStore = private {
/**
Returns the name of the store.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/name)
*/
@throws(JsExn)
@set
mutable name: string,
/**
Returns the key path of the store, or null if none.
Expand All @@ -164,15 +164,15 @@ type idbObjectStore = {
/**
IDBIndex interface of the WebApiIndexedDB API provides asynchronous access to an index in a database. An index is a kind of object store for looking up records in another object store, called the referenced object store. You use this interface to retrieve data.
[See IDBIndex on MDN](https://developer.mozilla.org/docs/Web/API/IDBIndex)
TODO: mark as private once mutating fields of private records is allowed
*/
@editor.completeFrom(IDBIndex)
type idbIndex = {
type idbIndex = private {
/**
Returns the name of the index.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBIndex/name)
*/
@throws(JsExn)
@set
mutable name: string,
/**
Returns the IDBObjectStore the index belongs to.
Expand Down
8 changes: 5 additions & 3 deletions tests/DOMAPI/AddEventListener__test.res
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
let button = DomGlobal.document->Document.querySelector("button")->Null.toOption
let h2 = DomGlobal.document->Document.querySelector("h2")->Null.toOption

module AnyElement = Element.Impl({type t = Element.t})

switch (button, h2) {
| (Some(button), Some(h2)) =>
button->Element.addEventListener(EventType.Click, (e: UiEventsTypes.mouseEvent) => {
Console.log(`Button clicked, ${Int.toString(e.button)}`)
switch h2.textContent {
| Null => h2.textContent = Value("1")
| Null => h2->AnyElement.setTextContent(Value("1"))
| Value(text) =>
switch Int.fromString(text) {
| None => h2.textContent = Value("1")
| Some(number) => h2.textContent = Value(Int.toString(number + 1))
| None => h2->AnyElement.setTextContent(Value("1"))
| Some(number) => h2->AnyElement.setTextContent(Value(Int.toString(number + 1)))
}
}
})
Expand Down
4 changes: 2 additions & 2 deletions tests/DOMAPI/HTMLSlotElement__test.res
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
let assignedNodesForElement = (element: DOMTree.element) =>
switch element.assignedSlot {
| Value(slot) =>
slot.name = "content"
slot->HTMLSlotElement.setName("content")
slot->HTMLSlotElement.assignedNodes
| Null => []
}

let assignedNodesForText = (text: Text.t) =>
switch text.assignedSlot {
| Value(slot) =>
slot.name = "content"
slot->HTMLSlotElement.setName("content")
slot->HTMLSlotElement.assignedNodes
| Null => []
}
9 changes: 4 additions & 5 deletions tests/FileAPI/ReadableStream__test.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ let strategy: FileTypes.queuingStrategy<string> = Obj.magic()

let _make: ReadableStream.t<string> = ReadableStream.make()

let _fromUnderlyingSource = ReadableStream.fromUnderlyingSource(underlyingSource)
let _fromUnderlyingSource: ReadableStream.t<string> =
ReadableStream.fromUnderlyingSource(underlyingSource)

let _fromUnderlyingSourceWithStrategy = ReadableStream.fromUnderlyingSource(
underlyingSource,
~strategy,
)
let _fromUnderlyingSourceWithStrategy: ReadableStream.t<string> =
ReadableStream.fromUnderlyingSource(underlyingSource, ~strategy)
Loading