mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibJS: Make more use of Value::is and Value::as_if in JS runtime
This commit is contained in:
committed by
Shannon Booth
parent
cadba4c0e7
commit
d7e828a366
Notes:
github-actions[bot]
2026-02-27 16:20:55 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/d7e828a3661 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8208 Reviewed-by: https://github.com/shannonbooth ✅
@@ -185,14 +185,14 @@ ThrowCompletionOr<bool> JSONObject::serialize_json_property(VM& vm, StringifySta
|
||||
value = TRY(value.to_primitive_string(vm));
|
||||
}
|
||||
// d. Else if value has a [[BooleanData]] internal slot, then
|
||||
else if (is<BooleanObject>(value_object)) {
|
||||
else if (auto const* boolean = as_if<BooleanObject>(value_object)) {
|
||||
// i. Set value to value.[[BooleanData]].
|
||||
value = Value(static_cast<BooleanObject&>(value_object).boolean());
|
||||
value = Value { boolean->boolean() };
|
||||
}
|
||||
// e. Else if value has a [[BigIntData]] internal slot, then
|
||||
else if (is<BigIntObject>(value_object)) {
|
||||
else if (auto const* bigint = as_if<BigIntObject>(value_object)) {
|
||||
// i. Set value to value.[[BigIntData]].
|
||||
value = Value(&static_cast<BigIntObject&>(value_object).bigint());
|
||||
value = Value { &bigint->bigint() };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,11 +912,8 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::raw_json)
|
||||
JS_DEFINE_NATIVE_FUNCTION(JSONObject::is_raw_json)
|
||||
{
|
||||
// 1. If Type(O) is Object and O has an [[IsRawJSON]] internal slot, return true.
|
||||
if (vm.argument(0).is_object() && is<RawJSONObject>(vm.argument(0).as_object()))
|
||||
return Value(true);
|
||||
|
||||
// 2. Return false.
|
||||
return Value(false);
|
||||
return vm.argument(0).is<RawJSONObject>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user