From 788085d376fa9ef5ac6f9cde96fe8b2f8e1a3ff1 Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 10 Feb 2019 16:43:42 +0800 Subject: [PATCH] Fix: also check elements after the last userstyle --- content/style-injector.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/content/style-injector.js b/content/style-injector.js index 39ad1fe8..ad7c02ba 100644 --- a/content/style-injector.js +++ b/content/style-injector.js @@ -38,15 +38,16 @@ function createStyleInjector({compare, setStyleContent, onUpdate}) { if (el.parentNode !== document.documentElement) { return true; } - let i = 1; - while (el && i < list.length) { - if (el.nextSibling === list[i].el) { + let i = 0; + while (el) { + if (i < list.length && el === list[i].el) { i++; } else if (ORDERED_TAGS.has(el.localName)) { - break; + return true; } el = el.nextSibling; } + // some styles are not injected to the document return i < list.length; }