pub fn script_type(
type_attr: Option<&str>,
language: Option<&str>,
) -> Option<SourceType>Expand description
How a browser runs a <script> with this type attribute and this
language attribute, as the HTML Standard decides it: as a script, as
a module, or, for None, not as JavaScript at all (a data block such
as application/json, or a template).
use parsec_js::SourceType;
use parsec_js::data::script_type;
assert_eq!(script_type(None, None), Some(SourceType::Script));
assert_eq!(script_type(Some(" Text/JavaScript "), None), Some(SourceType::Script));
assert_eq!(script_type(Some("module"), None), Some(SourceType::Module));
assert_eq!(script_type(Some("application/json"), None), None);
assert_eq!(script_type(None, Some("vbscript")), None);