diff --git a/dom/script/ScriptLoader.h b/dom/script/ScriptLoader.h index 80248e2dc9..71be1fa40b 100644 --- a/dom/script/ScriptLoader.h +++ b/dom/script/ScriptLoader.h @@ -324,7 +324,9 @@ class ScriptLoader final : public nsISupports : mOldScript(aScriptLoader->mCurrentScript) , mScriptLoader(aScriptLoader) { - mScriptLoader->mCurrentScript = aCurrentScript; + nsCOMPtr node = do_QueryInterface(aCurrentScript); + mScriptLoader->mCurrentScript = + node && !node->IsInShadowTree() ? aCurrentScript : nullptr; } ~AutoCurrentScriptUpdater() {