Skip to content

Commit

Permalink
LibWeb: Set script force async to false when async changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamierocks authored and tcl3 committed Aug 4, 2024
1 parent 77c41a8 commit bedb626
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions Tests/LibWeb/Text/expected/HTML/script-async-attribute.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
includeScript.async = false
script.async = true
script.async = false
4 changes: 4 additions & 0 deletions Tests/LibWeb/Text/input/HTML/script-async-attribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@

const script = document.createElement("script");
println(`script.async = ${script.async}`);

script.setAttribute("async", "true");
script.removeAttribute("async");
println(`script.async = ${script.async}`);
});
</script>
4 changes: 4 additions & 0 deletions Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ void HTMLScriptElement::attribute_changed(FlyString const& name, Optional<String
if (!is_parser_inserted() && is_connected() && value.has_value() && !old_value.has_value()) {
prepare_script();
}
} else if (name == HTML::AttributeNames::async) {
// https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model:script-force-async
// When an async attribute is added to a script element el, the user agent must set el's force async to false.
m_force_async = false;
}
}

Expand Down

0 comments on commit bedb626

Please sign in to comment.