Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/core/caniuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ export async function run(conf) {
// @ts-expect-error -- options is the normalized object form
const featureURL = new URL(options.feature, "https://caniuse.com/").href;
const headDlElem = document.querySelector(".head dl");
if (!headDlElem) {
const msg = `Can't render caniuse browser support table: no ".head dl" element was found.`;
showWarning(msg, name);
return;
Comment on lines +89 to +92
}
// @ts-expect-error -- options and conf.caniuse are the normalized object form
const contentPromise = fetchStats(conf.caniuse)
// @ts-expect-error -- options is object form
Expand All @@ -99,15 +104,15 @@ export async function run(conf) {
placeholder: "Fetching data from caniuse.com...",
}}
</dd>`;
headDlElem?.append(...definitionPair.childNodes);
headDlElem.append(...definitionPair.childNodes);
await contentPromise;
// @ts-expect-error -- options is the normalized object form
pub("amend-user-config", { caniuse: options.feature });
// @ts-expect-error -- options is the normalized object form
if (options.removeOnSave) {
// Will remove the browser support cells.
headDlElem
?.querySelectorAll(".caniuse-browser")
.querySelectorAll(".caniuse-browser")
.forEach(elem => elem.classList.add("removeOnSave"));
sub(
"beforesave",
Expand Down
Loading