mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Show warning when the script is a module
The warning can be removed in #23545.
This commit is contained in:
parent
70c5cfdbdb
commit
95ddfb3930
1 changed files with 58 additions and 36 deletions
|
@ -125,7 +125,7 @@ static SCRIPT_JS_MIMES: StaticStringVec = &[
|
||||||
"text/x-javascript",
|
"text/x-javascript",
|
||||||
];
|
];
|
||||||
|
|
||||||
#[derive(JSTraceable, MallocSizeOf)]
|
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
|
||||||
pub enum ScriptType {
|
pub enum ScriptType {
|
||||||
Classic,
|
Classic,
|
||||||
Module,
|
Module,
|
||||||
|
@ -388,7 +388,7 @@ impl HTMLScriptElement {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _script_type = if let Some(ty) = self.get_script_type() {
|
let script_type = if let Some(ty) = self.get_script_type() {
|
||||||
ty
|
ty
|
||||||
} else {
|
} else {
|
||||||
// Step 7.
|
// Step 7.
|
||||||
|
@ -493,6 +493,8 @@ impl HTMLScriptElement {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
match script_type {
|
||||||
|
ScriptType::Classic => {
|
||||||
// Preparation for step 26.
|
// Preparation for step 26.
|
||||||
let kind = if element.has_attribute(&local_name!("defer")) &&
|
let kind = if element.has_attribute(&local_name!("defer")) &&
|
||||||
was_parser_inserted &&
|
was_parser_inserted &&
|
||||||
|
@ -530,13 +532,33 @@ impl HTMLScriptElement {
|
||||||
ExternalScriptKind::AsapInOrder => doc.push_asap_in_order_script(self),
|
ExternalScriptKind::AsapInOrder => doc.push_asap_in_order_script(self),
|
||||||
ExternalScriptKind::Asap => doc.add_asap_script(self),
|
ExternalScriptKind::Asap => doc.add_asap_script(self),
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
ScriptType::Module => {
|
||||||
|
warn!(
|
||||||
|
"{} is a module script. It should be fixed after #23545 landed.",
|
||||||
|
url.clone()
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Step 25.
|
// Step 25.
|
||||||
assert!(!text.is_empty());
|
assert!(!text.is_empty());
|
||||||
|
|
||||||
// Step 25-1.
|
// Step 25-1.
|
||||||
let result = Ok(ScriptOrigin::internal(text, base_url, ScriptType::Classic));
|
let result = Ok(ScriptOrigin::internal(
|
||||||
|
text.clone(),
|
||||||
|
base_url.clone(),
|
||||||
|
script_type.clone(),
|
||||||
|
));
|
||||||
|
|
||||||
// TODO: Step 25-2.
|
// TODO: Step 25-2.
|
||||||
|
if let ScriptType::Module = script_type {
|
||||||
|
warn!(
|
||||||
|
"{} is a module script. It should be fixed after #23545 landed.",
|
||||||
|
base_url.clone()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Step 26.
|
// Step 26.
|
||||||
if was_parser_inserted &&
|
if was_parser_inserted &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue