mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb: Return instead of throwing on unknown enums in attribute setters
I saw one site relying on this, where they are trying to set XHR.responseType to "text/plain", which is not a valid responseType. However, they also don't expect it to throw. The IDL spec special cases enumerations to make it return instead of throwing in this case.
This commit is contained in:
parent
3fe66bddf4
commit
885c6b6678
Notes:
sideshowbarker
2024-07-17 09:52:29 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/885c6b6678 Pull-request: https://github.com/SerenityOS/serenity/pull/14406 Reviewed-by: https://github.com/linusg
1 changed files with 9 additions and 1 deletions
|
@ -605,10 +605,18 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
)~~~");
|
||||
}
|
||||
|
||||
enum_generator.append(R"~~~(
|
||||
// NOTE: Attribute setters return undefined instead of throwing when the string doesn't match an enum value.
|
||||
if constexpr (!IsSame<Attribute, RemoveConst<ParameterType>>) {
|
||||
enum_generator.append(R"~~~(
|
||||
@else@
|
||||
return vm.throw_completion<JS::TypeError>(global_object, JS::ErrorType::InvalidEnumerationValue, @js_name.as_string@, "@parameter.type.name@");
|
||||
)~~~");
|
||||
} else {
|
||||
enum_generator.append(R"~~~(
|
||||
@else@
|
||||
return JS::js_undefined();
|
||||
)~~~");
|
||||
}
|
||||
|
||||
if (optional) {
|
||||
enum_generator.append(R"~~~(
|
||||
|
|
Loading…
Add table
Reference in a new issue