From 57442b5e1907dff3ae36ab68a09a6a5e14b5d14d Mon Sep 17 00:00:00 2001 From: "Sideways S." Date: Sun, 6 Oct 2024 09:58:45 -0600 Subject: [PATCH 1/2] use Set to filter localNames --- .../en-us/web/api/customelementregistry/whendefined/index.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/customelementregistry/whendefined/index.md b/files/en-us/web/api/customelementregistry/whendefined/index.md index 26db8eea1906850..22f5fb56e8360f5 100644 --- a/files/en-us/web/api/customelementregistry/whendefined/index.md +++ b/files/en-us/web/api/customelementregistry/whendefined/index.md @@ -54,9 +54,10 @@ const placeholder = container.querySelector(".menu-placeholder"); const undefinedElements = container.querySelectorAll(":not(:defined)"); async function removePlaceholder() { - const promises = [...undefinedElements].map((button) => - customElements.whenDefined(button.localName), + const tags = new Set( + [...undefinedElements].map((button) => button.localName), ); + const promises = [...tags].map((tag) => customElements.whenDefined(tag)); // Wait for all the children to be upgraded await Promise.all(promises); From 9d63ff145973cc2d055a4be9fb835fcd3280eda1 Mon Sep 17 00:00:00 2001 From: "Sideways S." Date: Sun, 6 Oct 2024 10:15:54 -0600 Subject: [PATCH 2/2] Added comment --- files/en-us/web/api/customelementregistry/whendefined/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/files/en-us/web/api/customelementregistry/whendefined/index.md b/files/en-us/web/api/customelementregistry/whendefined/index.md index 22f5fb56e8360f5..35dc91fb6b28949 100644 --- a/files/en-us/web/api/customelementregistry/whendefined/index.md +++ b/files/en-us/web/api/customelementregistry/whendefined/index.md @@ -54,6 +54,7 @@ const placeholder = container.querySelector(".menu-placeholder"); const undefinedElements = container.querySelectorAll(":not(:defined)"); async function removePlaceholder() { + // Filter the elements down to unique localNames const tags = new Set( [...undefinedElements].map((button) => button.localName), );