1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:08:12 +00:00

LibWeb: Fix check for missing argument in Animation constructor

Receiving a null argument has a different result than not passing an
argument at all.
This commit is contained in:
Matthew Olsson 2024-02-10 21:11:40 -07:00 committed by Andrew Kaster
parent bd74447dba
commit ce99636cd0

View file

@ -23,13 +23,15 @@ JS_DEFINE_ALLOCATOR(Animation);
// https://www.w3.org/TR/web-animations-1/#dom-animation-animation
JS::NonnullGCPtr<Animation> Animation::create(JS::Realm& realm, JS::GCPtr<AnimationEffect> effect, JS::GCPtr<AnimationTimeline> timeline)
{
auto& vm = realm.vm();
// 1. Let animation be a new Animation object.
auto animation = realm.heap().allocate<Animation>(realm, realm);
// 2. Run the procedure to set the timeline of an animation on animation passing timeline as the new timeline or, if
// a timeline argument is missing, passing the default document timeline of the Document associated with the
// Window that is the current global object.
if (!timeline) {
if (vm.argument_count() < 2) {
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
timeline = window.associated_document().timeline();
}