mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Add ScriptType::ImportMap
Signed-off-by: Yu Wei Wu <yuweiwu@YunoMacBook-Air.local>
This commit is contained in:
parent
c7eba2dbba
commit
3d41e26d7d
1 changed files with 27 additions and 25 deletions
|
@ -275,6 +275,7 @@ pub(crate) static SCRIPT_JS_MIMES: StaticStringVec = &[
|
||||||
pub(crate) enum ScriptType {
|
pub(crate) enum ScriptType {
|
||||||
Classic,
|
Classic,
|
||||||
Module,
|
Module,
|
||||||
|
ImportMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(JSTraceable, MallocSizeOf)]
|
#[derive(JSTraceable, MallocSizeOf)]
|
||||||
|
@ -770,14 +771,15 @@ impl HTMLScriptElement {
|
||||||
// Step 23. Module script credentials mode.
|
// Step 23. Module script credentials mode.
|
||||||
let module_credentials_mode = match script_type {
|
let module_credentials_mode = match script_type {
|
||||||
ScriptType::Classic => CredentialsMode::CredentialsSameOrigin,
|
ScriptType::Classic => CredentialsMode::CredentialsSameOrigin,
|
||||||
ScriptType::Module => reflect_cross_origin_attribute(element).map_or(
|
ScriptType::Module | ScriptType::ImportMap => reflect_cross_origin_attribute(element)
|
||||||
CredentialsMode::CredentialsSameOrigin,
|
.map_or(
|
||||||
|attr| match &*attr {
|
CredentialsMode::CredentialsSameOrigin,
|
||||||
"use-credentials" => CredentialsMode::Include,
|
|attr| match &*attr {
|
||||||
"anonymous" => CredentialsMode::CredentialsSameOrigin,
|
"use-credentials" => CredentialsMode::Include,
|
||||||
_ => CredentialsMode::CredentialsSameOrigin,
|
"anonymous" => CredentialsMode::CredentialsSameOrigin,
|
||||||
},
|
_ => CredentialsMode::CredentialsSameOrigin,
|
||||||
),
|
},
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Step 24. Let cryptographic nonce be el's [[CryptographicNonce]] internal slot's value.
|
// Step 24. Let cryptographic nonce be el's [[CryptographicNonce]] internal slot's value.
|
||||||
|
@ -904,7 +906,7 @@ impl HTMLScriptElement {
|
||||||
doc.add_asap_script(self);
|
doc.add_asap_script(self);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
// TODO: Case "importmap"
|
ScriptType::ImportMap => (),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Step 32. If el does not have a src content attribute:
|
// Step 32. If el does not have a src content attribute:
|
||||||
|
@ -913,18 +915,17 @@ impl HTMLScriptElement {
|
||||||
|
|
||||||
let text_rc = Rc::new(text);
|
let text_rc = Rc::new(text);
|
||||||
|
|
||||||
// TODO: Fix step number or match spec text. Is this step 32.1?
|
// Step 32.2: Switch on el's type:
|
||||||
let result = Ok(ScriptOrigin::internal(
|
|
||||||
Rc::clone(&text_rc),
|
|
||||||
base_url.clone(),
|
|
||||||
options.clone(),
|
|
||||||
script_type,
|
|
||||||
self.global().unminified_js_dir(),
|
|
||||||
));
|
|
||||||
|
|
||||||
// TODO: Fix step number or match spec text. Is this step 32.2?
|
|
||||||
match script_type {
|
match script_type {
|
||||||
ScriptType::Classic => {
|
ScriptType::Classic => {
|
||||||
|
let result = Ok(ScriptOrigin::internal(
|
||||||
|
Rc::clone(&text_rc),
|
||||||
|
base_url.clone(),
|
||||||
|
options.clone(),
|
||||||
|
script_type,
|
||||||
|
self.global().unminified_js_dir(),
|
||||||
|
));
|
||||||
|
|
||||||
if was_parser_inserted &&
|
if was_parser_inserted &&
|
||||||
doc.get_current_parser()
|
doc.get_current_parser()
|
||||||
.is_some_and(|parser| parser.script_nesting_level() <= 1) &&
|
.is_some_and(|parser| parser.script_nesting_level() <= 1) &&
|
||||||
|
@ -958,6 +959,9 @@ impl HTMLScriptElement {
|
||||||
can_gc,
|
can_gc,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
ScriptType::ImportMap => {
|
||||||
|
// TODO: Let result be the result of creating an import map parse result given source text and base URL.
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1054,19 +1058,17 @@ impl HTMLScriptElement {
|
||||||
} else {
|
} else {
|
||||||
document.set_current_script(Some(self))
|
document.set_current_script(Some(self))
|
||||||
}
|
}
|
||||||
},
|
|
||||||
ScriptType::Module => document.set_current_script(None),
|
|
||||||
}
|
|
||||||
|
|
||||||
match script.type_ {
|
|
||||||
ScriptType::Classic => {
|
|
||||||
self.run_a_classic_script(&script, can_gc);
|
self.run_a_classic_script(&script, can_gc);
|
||||||
document.set_current_script(old_script.as_deref());
|
document.set_current_script(old_script.as_deref());
|
||||||
},
|
},
|
||||||
ScriptType::Module => {
|
ScriptType::Module => {
|
||||||
|
document.set_current_script(None);
|
||||||
assert!(document.GetCurrentScript().is_none());
|
assert!(document.GetCurrentScript().is_none());
|
||||||
self.run_a_module_script(&script, false, can_gc);
|
self.run_a_module_script(&script, false, can_gc);
|
||||||
},
|
},
|
||||||
|
ScriptType::ImportMap => {
|
||||||
|
// TODO: Register an import map given el's relevant global object and el's result.
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 7.
|
// Step 7.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue