Skip to content

Commit

Permalink
Fix the bindings for performance.now() and document.*
Browse files Browse the repository at this point in the history
performance.now() and co. need to be called with the proper this value.
  • Loading branch information
CountBleck committed Feb 25, 2023
1 parent 7a35ff8 commit 65ce44b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions std/assembly/bindings/dom.ts
Expand Up @@ -229,54 +229,65 @@ export declare namespace document {
* @param tagName The name of an element.
*/
@external("env", "document.createElement")
@external.js("return document.createElement(tagName);")
export function createElement(tagName: string /* , options?: ElementCreationOptions */): externref;
/**
* Returns a reference to the first HTMLElement object with the specified value of the ID attribute.
* @param id String that specifies the ID value.
*/
@external("env", "document.getElementById")
@external.js("return document.getElementById(id);")
export function getElementById(id: string): externref;
/**
* Returns a HTMLCollection of the elements in the object on which the method was invoked that have all the classes
* given by classNames. The classNames argument is interpreted as a space-separated list of classes.
* @param classNames Gets a collection of objects based on the value of the CLASS attribute.
*/
@external("env", "document.getElementsByClassName")
@external.js("return document.getElementsByClassName(classNames);")
export function getElementsByClassName(classNames: string): externref;
/**
* Gets a collection of HTMLElement objects based on the value of the NAME or ID attribute.
* @param elementName Gets a collection of objects based on the value of the NAME or ID attribute.
*/
@external("env", "document.getElementsByName")
@external.js("return document.getElementsByName(elementName);")
export function getElementsByName(elementName: string): externref;
/** Gets a value indicating whether the object currently has focus. */
@external("env", "document.hasFocus")
@external.js("return document.hasFocus();")
export function hasFocus(): bool;
/** Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes. */
@external("env", "document.append")
@external.js("return document.append(node);")
export function append(node: externref): void;
/** Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes. */
@external("env", "document.prepend")
@external.js("return document.prepend(node);")
export function prepend(node: externref): void;
/** Replace all children of node with nodes, while replacing strings in nodes with equivalent Text nodes. */
@external("env", "document.replaceChildren")
@external.js("return document.replaceChildren(node);")
export function replaceChildren(node: externref): void;
/**
* Writes one or more HTML expressions to a document in the specified window.
* @param content Specifies the text and HTML tags to write.
*/
@external("env", "document.write")
@external.js("return document.write(content);")
export function write(content: string): void;
/**
* Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window.
* @param content Specifies the text and HTML tags to write.
*/
@external("env", "document.writeln")
@external.js("return document.writeln(content);")
export function writeln(content: string): void;
}

export declare namespace performance {
@external("env", "performance.now")
@external.js("return performance.now();")
export function now(): f64;
}

Expand Down

0 comments on commit 65ce44b

Please sign in to comment.