chore(highlights_list): improve performance by matching fewer elements

This commit is contained in:
Elian Doran 2025-12-18 13:38:52 +02:00
parent d18ac0c613
commit 751a874c51
No known key found for this signature in database

View File

@ -180,6 +180,8 @@ function ReadOnlyTextHighlightsList() {
function extractHeadingsFromStaticHtml(el: HTMLElement | null) { function extractHeadingsFromStaticHtml(el: HTMLElement | null) {
if (!el) return []; if (!el) return [];
const { color: defaultColor, backgroundColor: defaultBackgroundColor } = getComputedStyle(el);
const walker = document.createTreeWalker( const walker = document.createTreeWalker(
el, el,
NodeFilter.SHOW_TEXT, NodeFilter.SHOW_TEXT,
@ -197,7 +199,8 @@ function extractHeadingsFromStaticHtml(el: HTMLElement | null) {
if ( if (
el.closest('strong, em, u') || el.closest('strong, em, u') ||
style.color || style.backgroundColor style.color !== defaultColor ||
style.backgroundColor !== defaultBackgroundColor
) { ) {
const attrs: RawHighlight["attrs"] = { const attrs: RawHighlight["attrs"] = {
bold: !!el.closest("strong"), bold: !!el.closest("strong"),