diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 1bd06a79c47..78c2040cfd1 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -6679,7 +6679,6 @@ void Document::set_onvisibilitychange(WebIDL::CallbackType* value) } // https://drafts.csswg.org/css-view-transitions-1/#dom-document-startviewtransition -// FIXME: Calling document.startViewTransition() without arguments throws TypeError instead of calling this. GC::Ptr Document::start_view_transition(ViewTransition::ViewTransitionUpdateCallback update_callback) { // The method steps for startViewTransition(updateCallback) are as follows: diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 7d0256d7e6d..18593255781 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -1089,17 +1089,22 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter // 1. If the result of calling IsCallable(V) is false and the conversion to an IDL value is not being performed due to V being assigned to an attribute whose type is a nullable callback function that is annotated with [LegacyTreatNonObjectAsNull], then throw a TypeError. if (!parameter.type->is_nullable() && !callback_function.is_legacy_treat_non_object_as_null) { callback_function_generator.append(R"~~~( - if (!@js_name@@js_suffix@.is_function()) + if (!@js_name@@js_suffix@.is_function() +)~~~"); + if (optional) + callback_function_generator.append("&& !@js_name@@js_suffix@.is_undefined()"); + callback_function_generator.append(R"~~~() return vm.throw_completion(JS::ErrorType::NotAFunction, @js_name@@js_suffix@.to_string_without_side_effects()); )~~~"); } // 2. Return the IDL callback function type value that represents a reference to the same object that V represents, with the incumbent realm as the callback context. - if (parameter.type->is_nullable() || callback_function.is_legacy_treat_non_object_as_null) { + if (optional || parameter.type->is_nullable() || callback_function.is_legacy_treat_non_object_as_null) { callback_function_generator.append(R"~~~( GC::Ptr @cpp_name@; if (@js_name@@js_suffix@.is_object()) @cpp_name@ = vm.heap().allocate(@js_name@@js_suffix@.as_object(), HTML::incumbent_realm(), @operation_returns_promise@); )~~~"); + // FIXME: Handle default value for optional parameter here. } else { callback_function_generator.append(R"~~~( auto @cpp_name@ = vm.heap().allocate(@js_name@@js_suffix@.as_object(), HTML::incumbent_realm(), @operation_returns_promise@);