From e5a5e115ca1fb1019884a78a919a10c191954e1d Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Sun, 16 Feb 2025 05:51:22 -0500 Subject: [PATCH] Fix microtask usage guide code example (#38176) --- files/en-us/web/api/html_dom_api/microtask_guide/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/html_dom_api/microtask_guide/index.md b/files/en-us/web/api/html_dom_api/microtask_guide/index.md index 4e82424abb7e6b2..6372dbaa666bbaf 100644 --- a/files/en-us/web/api/html_dom_api/microtask_guide/index.md +++ b/files/en-us/web/api/html_dom_api/microtask_guide/index.md @@ -74,7 +74,7 @@ The main reason to use microtasks is that: to ensure consistent ordering of task One situation in which microtasks can be used to ensure that the ordering of execution is always consistent is when promises are used in one clause of an `if...else` statement (or other conditional statement), but not in the other clause. Consider code such as this: ```js -customElement.prototype.getData = (url) => { +customElement.prototype.getData = function (url) { if (this.cache[url]) { this.data = this.cache[url]; this.dispatchEvent(new Event("load")); @@ -122,7 +122,7 @@ Even worse, sometimes the element's `data` property will be set and other times We can ensure consistent ordering of these operations by using a microtask in the `if` clause to balance the two clauses: ```js -customElement.prototype.getData = (url) => { +customElement.prototype.getData = function (url) { if (this.cache[url]) { queueMicrotask(() => { this.data = this.cache[url];