Index: Source/core/html/HTMLScriptElement.cpp |
diff --git a/Source/core/html/HTMLScriptElement.cpp b/Source/core/html/HTMLScriptElement.cpp |
index b95da30566f265e2ee01c80206b1bf2fb71d00ee..d9cbb807932fd94953cdd369c50532709825225c 100644 |
--- a/Source/core/html/HTMLScriptElement.cpp |
+++ b/Source/core/html/HTMLScriptElement.cpp |
@@ -73,7 +73,8 @@ void HTMLScriptElement::childrenChanged(const ChildrenChange& change) |
void HTMLScriptElement::didMoveToNewDocument(Document& oldDocument) |
{ |
- oldDocument.scriptRunner()->movePendingAsyncScript(document().scriptRunner(), m_loader.get()); |
+ if (RefPtrWillBeRawPtr<Document> contextDocument = document().contextDocument().get()) |
+ oldDocument.scriptRunner()->movePendingAsyncScript(contextDocument->scriptRunner(), m_loader.get()); |
HTMLElement::didMoveToNewDocument(oldDocument); |
} |