Skip to content

Commit 65ce44b

Browse files
committed
Fix the bindings for performance.now() and document.*
performance.now() and co. need to be called with the proper this value.
1 parent 7a35ff8 commit 65ce44b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: std/assembly/bindings/dom.ts

+11
Original file line numberDiff line numberDiff line change
@@ -229,54 +229,65 @@ export declare namespace document {
229229
* @param tagName The name of an element.
230230
*/
231231
@external("env", "document.createElement")
232+
@external.js("return document.createElement(tagName);")
232233
export function createElement(tagName: string /* , options?: ElementCreationOptions */): externref;
233234
/**
234235
* Returns a reference to the first HTMLElement object with the specified value of the ID attribute.
235236
* @param id String that specifies the ID value.
236237
*/
237238
@external("env", "document.getElementById")
239+
@external.js("return document.getElementById(id);")
238240
export function getElementById(id: string): externref;
239241
/**
240242
* Returns a HTMLCollection of the elements in the object on which the method was invoked that have all the classes
241243
* given by classNames. The classNames argument is interpreted as a space-separated list of classes.
242244
* @param classNames Gets a collection of objects based on the value of the CLASS attribute.
243245
*/
244246
@external("env", "document.getElementsByClassName")
247+
@external.js("return document.getElementsByClassName(classNames);")
245248
export function getElementsByClassName(classNames: string): externref;
246249
/**
247250
* Gets a collection of HTMLElement objects based on the value of the NAME or ID attribute.
248251
* @param elementName Gets a collection of objects based on the value of the NAME or ID attribute.
249252
*/
250253
@external("env", "document.getElementsByName")
254+
@external.js("return document.getElementsByName(elementName);")
251255
export function getElementsByName(elementName: string): externref;
252256
/** Gets a value indicating whether the object currently has focus. */
253257
@external("env", "document.hasFocus")
258+
@external.js("return document.hasFocus();")
254259
export function hasFocus(): bool;
255260
/** Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes. */
256261
@external("env", "document.append")
262+
@external.js("return document.append(node);")
257263
export function append(node: externref): void;
258264
/** Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes. */
259265
@external("env", "document.prepend")
266+
@external.js("return document.prepend(node);")
260267
export function prepend(node: externref): void;
261268
/** Replace all children of node with nodes, while replacing strings in nodes with equivalent Text nodes. */
262269
@external("env", "document.replaceChildren")
270+
@external.js("return document.replaceChildren(node);")
263271
export function replaceChildren(node: externref): void;
264272
/**
265273
* Writes one or more HTML expressions to a document in the specified window.
266274
* @param content Specifies the text and HTML tags to write.
267275
*/
268276
@external("env", "document.write")
277+
@external.js("return document.write(content);")
269278
export function write(content: string): void;
270279
/**
271280
* Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window.
272281
* @param content Specifies the text and HTML tags to write.
273282
*/
274283
@external("env", "document.writeln")
284+
@external.js("return document.writeln(content);")
275285
export function writeln(content: string): void;
276286
}
277287

278288
export declare namespace performance {
279289
@external("env", "performance.now")
290+
@external.js("return performance.now();")
280291
export function now(): f64;
281292
}
282293

0 commit comments

Comments
 (0)