@@ -108,7 +108,7 @@ void HTMLScriptElement::execute_script()
108
108
document->set_current_script ({}, nullptr );
109
109
110
110
if (m_from_an_external_file)
111
- dbgln_if (HTML_SCRIPT_DEBUG, " HTMLScriptElement: Running script {}" , deprecated_attribute (HTML::AttributeNames::src));
111
+ dbgln_if (HTML_SCRIPT_DEBUG, " HTMLScriptElement: Running script {}" , attribute (HTML::AttributeNames::src). value_or (String {} ));
112
112
else
113
113
dbgln_if (HTML_SCRIPT_DEBUG, " HTMLScriptElement: Running inline script" );
114
114
@@ -177,28 +177,28 @@ void HTMLScriptElement::prepare_script()
177
177
// - el has a type attribute whose value is the empty string;
178
178
// - el has no type attribute but it has a language attribute and that attribute's value is the empty string; or
179
179
// - el has neither a type attribute nor a language attribute
180
- ByteString script_block_type;
181
- bool has_type_attribute = has_attribute (HTML::AttributeNames::type);
182
- bool has_language_attribute = has_attribute (HTML::AttributeNames::language);
183
- if ((has_type_attribute && deprecated_attribute (HTML::AttributeNames::type). is_empty ())
184
- || (!has_type_attribute && has_language_attribute && deprecated_attribute (HTML::AttributeNames::language). is_empty ())
185
- || (!has_type_attribute && !has_language_attribute )) {
180
+ String script_block_type;
181
+ auto maybe_type_attribute = attribute (HTML::AttributeNames::type);
182
+ auto maybe_language_attribute = attribute (HTML::AttributeNames::language);
183
+ if ((maybe_type_attribute. has_value () && maybe_type_attribute-> is_empty ())
184
+ || (!maybe_type_attribute. has_value () && maybe_language_attribute. has_value () && maybe_language_attribute-> is_empty ())
185
+ || (!maybe_type_attribute. has_value () && !maybe_language_attribute. has_value () )) {
186
186
// then let the script block's type string for this script element be "text/javascript".
187
- script_block_type = " text/javascript" ;
187
+ script_block_type = " text/javascript" _string ;
188
188
}
189
189
// Otherwise, if el has a type attribute,
190
- else if (has_type_attribute ) {
190
+ else if (maybe_type_attribute. has_value () ) {
191
191
// then let the script block's type string be the value of that attribute with leading and trailing ASCII whitespace stripped.
192
- script_block_type = deprecated_attribute (HTML::AttributeNames::type). trim (Infra::ASCII_WHITESPACE);
192
+ script_block_type = MUST (maybe_type_attribute-> trim (Infra::ASCII_WHITESPACE) );
193
193
}
194
194
// Otherwise, el has a non-empty language attribute;
195
- else if (! deprecated_attribute (HTML::AttributeNames::language). is_empty ()) {
195
+ else if (maybe_language_attribute. has_value () && !maybe_language_attribute-> is_empty ()) {
196
196
// let the script block's type string be the concatenation of "text/" and the value of el's language attribute.
197
- script_block_type = ByteString ::formatted (" text/{}" , deprecated_attribute (HTML::AttributeNames::language ));
197
+ script_block_type = MUST ( String ::formatted (" text/{}" , maybe_language_attribute. value () ));
198
198
}
199
199
200
200
// 9. If the script block's type string is a JavaScript MIME type essence match,
201
- if (MimeSniff::is_javascript_mime_type_essence_match (script_block_type.trim (Infra::ASCII_WHITESPACE))) {
201
+ if (MimeSniff::is_javascript_mime_type_essence_match (MUST ( script_block_type.trim (Infra::ASCII_WHITESPACE) ))) {
202
202
// then set el's type to "classic".
203
203
m_script_type = ScriptType::Classic;
204
204
}
0 commit comments