Index: Source/core/dom/ScriptElement.cpp |
diff --git a/Source/core/dom/ScriptElement.cpp b/Source/core/dom/ScriptElement.cpp |
index 6b5873893dd4efd1916cd66ccff94a1ac14bf5ad..7c9061ae4c9a7948a07daf4adf071d14ef227e3b 100644 |
--- a/Source/core/dom/ScriptElement.cpp |
+++ b/Source/core/dom/ScriptElement.cpp |
@@ -282,6 +282,11 @@ bool ScriptElement::requestScript(const String& sourceUrl) |
return false; |
} |
+bool isHTMLScriptElement(Element* element) |
+{ |
+ return element->isHTMLElement() && element->hasTagName(HTMLNames::scriptTag); |
+} |
+ |
void ScriptElement::executeScript(const ScriptSourceCode& sourceCode) |
{ |
ASSERT(m_alreadyStarted); |
@@ -307,10 +312,16 @@ void ScriptElement::executeScript(const ScriptSourceCode& sourceCode) |
if (frame) { |
{ |
IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer(m_isExternalScript ? document.get() : 0); |
+ |
+ if (isHTMLScriptElement(m_element)) |
+ document->setCurrentScript(static_cast<HTMLScriptElement*>(m_element)); |
+ |
// Create a script from the script element node, using the script |
// block's source and the script block's type. |
// Note: This is where the script is compiled and actually executed. |
frame->script()->evaluate(sourceCode); |
+ |
+ document->setCurrentScript(0); |
esprehn
2013/05/14 22:50:09
I think you want to check that document->currentSc
|
} |
} |
} |
@@ -417,7 +428,7 @@ String ScriptElement::scriptContent() const |
ScriptElement* toScriptElementIfPossible(Element* element) |
{ |
- if (element->isHTMLElement() && element->hasTagName(HTMLNames::scriptTag)) |
+ if (isHTMLScriptElement(element)) |
return static_cast<HTMLScriptElement*>(element); |
#if ENABLE(SVG) |