aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlscriptelement.rs
diff options
context:
space:
mode:
authorbors-servo <servo-ops@mozilla.com>2020-05-27 08:58:36 -0400
committerGitHub <noreply@github.com>2020-05-27 08:58:36 -0400
commit4094d1632327e9b95e6a93b91b91bbb38dabbfc6 (patch)
tree7a3d9c84180cd44e12e08b0a62f22bd02a89ae94 /components/script/dom/htmlscriptelement.rs
parent280c48846c8640fcddabc868a02190147e10d7a7 (diff)
parenta0df94bddcc71e03961fea76f2bf7569eaeb3a53 (diff)
downloadservo-4094d1632327e9b95e6a93b91b91bbb38dabbfc6.tar.gz
servo-4094d1632327e9b95e6a93b91b91bbb38dabbfc6.zip
Auto merge of #26668 - CYBAI:fix-module-current-script, r=jdm
Set `currentScript` to `null` for module scripts I misunderstood the test case when I worked on #23545. That test case is actually not related to dynamic import; instead, the reason why it crashes is, `currentScript` should be updated to `null`. In spec, the step 6 of [execute-the-script-block](https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block) only says `Assert: document's currentScript attribute is null.` but doesn't says it should be set to null. Not sure if it can be improved. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/dom/htmlscriptelement.rs')
-rw-r--r--components/script/dom/htmlscriptelement.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs
index f7311ddaca4..8d0d9f219c1 100644
--- a/components/script/dom/htmlscriptelement.rs
+++ b/components/script/dom/htmlscriptelement.rs
@@ -757,13 +757,17 @@ impl HTMLScriptElement {
let old_script = document.GetCurrentScript();
match script.type_ {
+ ScriptType::Classic => document.set_current_script(Some(self)),
+ ScriptType::Module => document.set_current_script(None),
+ }
+
+ match script.type_ {
ScriptType::Classic => {
- document.set_current_script(Some(self));
self.run_a_classic_script(&script);
document.set_current_script(old_script.as_deref());
},
ScriptType::Module => {
- assert!(old_script.is_none());
+ assert!(document.GetCurrentScript().is_none());
self.run_a_module_script(&script, false);
},
}