From 665fd8c54fb5aa812bd7c64a98024c1419a7546e Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Tue, 27 Feb 2024 01:24:31 -0800 Subject: [PATCH] Only highlight if CSS Custom Highlight API is supported Firefox is still rolling out support: https://caniuse.com/mdn-api_highlight --- script.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index 5a1f46e..c2dd912 100644 --- a/script.js +++ b/script.js @@ -214,8 +214,10 @@ function showSearch(query) { range.setEnd(node, start + query.length); ranges.push(range); } - const highlight = new Highlight(...ranges); - CSS.highlights.set('search', highlight); + if (CSS.highlights !== undefined) { + const highlight = new Highlight(...ranges); + CSS.highlights.set('search', highlight); + } document.querySelector('main').replaceWith(filteredHome); } -- 2.47.3