diff --git a/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Libraries/LibJS/Bytecode/ASTCodegen.cpp index 13732eef188..14ab23641be 100644 --- a/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -630,6 +630,13 @@ Bytecode::CodeGenerationErrorOr> AssignmentExpression::g // e. Perform ? PutValue(lref, rval). if (is(*lhs)) { auto& identifier = static_cast(*lhs); + if (identifier.is_local()) { + auto is_initialized = generator.is_local_initialized(identifier.local_index()); + auto is_lexically_declared = generator.is_local_lexically_declared(identifier.local_index()); + if (is_lexically_declared && !is_initialized) { + generator.emit(generator.local(identifier.local_index())); + } + } generator.emit_set_variable(identifier, rval); } else if (is(*lhs)) { auto& expression = static_cast(*lhs); diff --git a/Tests/LibWeb/Text/input/WebAnimations/animation-methods/persist.html b/Tests/LibWeb/Text/input/WebAnimations/animation-methods/persist.html index 372fb4ad7cb..c1b0c3f63b0 100644 --- a/Tests/LibWeb/Text/input/WebAnimations/animation-methods/persist.html +++ b/Tests/LibWeb/Text/input/WebAnimations/animation-methods/persist.html @@ -13,15 +13,15 @@ anim.cancel(); // "Undo" the removal of an animation by the Document - anim1 = foo.animate({ opacity: 0 }, { duration: 1, fill: 'forwards' }); - anim2 = foo.animate({ opacity: 0 }, { duration: 1, fill: 'forwards' }); + let anim1 = foo.animate({ opacity: 0 }, { duration: 1, fill: 'forwards' }); + let anim2 = foo.animate({ opacity: 0 }, { duration: 1, fill: 'forwards' }); await anim1.finished; anim1.persist(); println(`persist() undoes the Document removal effects: ${foo.getAnimations().length === 2}`); const timeline = internals.createInternalAnimationTimeline(); - let anim1 = foo.animate({ opacity: 0 }, { duration: 1000, fill: "forwards", timeline }); - let anim2 = foo.animate({ opacity: 0 }, { duration: 500, fill: "forwards", timeline }); + anim1 = foo.animate({ opacity: 0 }, { duration: 1000, fill: "forwards", timeline }); + anim2 = foo.animate({ opacity: 0 }, { duration: 500, fill: "forwards", timeline }); timeline.setTime(1500); await animationFrame(); if (anim1.replaceState === "removed" && anim2.replaceState === "active")