diff --git a/CHANGELOG.md b/CHANGELOG.md index 608fc227f42..bcc66f5c606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,9 @@ * Add bindings for `VisualViewport`. [#3931](https://github.com/rustwasm/wasm-bindgen/pull/3931) +* Add bindings for `queueMicrotask`. + [#3981](https://github.com/rustwasm/wasm-bindgen/pull/3981) + ### Changed * Stabilize Web Share API. diff --git a/crates/web-sys/src/features/gen_Window.rs b/crates/web-sys/src/features/gen_Window.rs index 42273a69712..f0d74ecb39d 100644 --- a/crates/web-sys/src/features/gen_Window.rs +++ b/crates/web-sys/src/features/gen_Window.rs @@ -3001,6 +3001,13 @@ extern "C" { input: &str, init: &RequestInit, ) -> ::js_sys::Promise; + # [wasm_bindgen (method , structural , js_class = "Window" , js_name = queueMicrotask)] + #[doc = "The `queueMicrotask()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Window/queueMicrotask)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Window`*"] + pub fn queue_microtask(this: &Window, callback: &::js_sys::Function); # [wasm_bindgen (catch , method , structural , js_class = "Window" , js_name = setInterval)] #[doc = "The `setInterval()` method."] #[doc = ""] diff --git a/crates/web-sys/src/features/gen_WorkerGlobalScope.rs b/crates/web-sys/src/features/gen_WorkerGlobalScope.rs index df08803f585..d46c62d8211 100644 --- a/crates/web-sys/src/features/gen_WorkerGlobalScope.rs +++ b/crates/web-sys/src/features/gen_WorkerGlobalScope.rs @@ -820,6 +820,13 @@ extern "C" { input: &str, init: &RequestInit, ) -> ::js_sys::Promise; + # [wasm_bindgen (method , structural , js_class = "WorkerGlobalScope" , js_name = queueMicrotask)] + #[doc = "The `queueMicrotask()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/queueMicrotask)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `WorkerGlobalScope`*"] + pub fn queue_microtask(this: &WorkerGlobalScope, callback: &::js_sys::Function); # [wasm_bindgen (catch , method , structural , js_class = "WorkerGlobalScope" , js_name = setInterval)] #[doc = "The `setInterval()` method."] #[doc = ""] diff --git a/crates/web-sys/webidls/enabled/WindowOrWorkerGlobalScope.webidl b/crates/web-sys/webidls/enabled/WindowOrWorkerGlobalScope.webidl index 89b818c4b63..3c06b1bf716 100644 --- a/crates/web-sys/webidls/enabled/WindowOrWorkerGlobalScope.webidl +++ b/crates/web-sys/webidls/enabled/WindowOrWorkerGlobalScope.webidl @@ -68,3 +68,8 @@ partial interface mixin WindowOrWorkerGlobalScope { [Throws, Func="mozilla::dom::DOMPrefs::DOMCachesEnabled", SameObject] readonly attribute CacheStorage caches; }; + +// https://html.spec.whatwg.org/#microtask-queuing +partial interface mixin WindowOrWorkerGlobalScope { + undefined queueMicrotask(VoidFunction callback); +};