From 65ce44baec35e8e2404fed689b478c274a8c8913 Mon Sep 17 00:00:00 2001 From: CountBleck Date: Sat, 25 Feb 2023 15:27:45 -0800 Subject: [PATCH] Fix the bindings for performance.now() and document.* performance.now() and co. need to be called with the proper this value. --- std/assembly/bindings/dom.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/std/assembly/bindings/dom.ts b/std/assembly/bindings/dom.ts index 85c59ffc46..c84681e14a 100644 --- a/std/assembly/bindings/dom.ts +++ b/std/assembly/bindings/dom.ts @@ -229,12 +229,14 @@ 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 @@ -242,41 +244,50 @@ export declare namespace document { * @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; }