mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 21:20:18 +00:00
LibJS: Implement console.dirxml
This function actually gets tested in WPT.
This commit is contained in:
parent
ad06ac0d58
commit
08284e0ef6
Notes:
github-actions[bot]
2025-08-17 11:29:56 +00:00
Author: https://github.com/tete17
Commit: 08284e0ef6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5861
Reviewed-by: https://github.com/trflynn89
5 changed files with 40 additions and 1 deletions
|
@ -398,6 +398,34 @@ ThrowCompletionOr<Value> Console::dir()
|
|||
return js_undefined();
|
||||
}
|
||||
|
||||
// 1.1.11 dirxml(...data) https://console.spec.whatwg.org/#dirxml
|
||||
ThrowCompletionOr<Value> Console::dirxml()
|
||||
{
|
||||
auto& vm = realm().vm();
|
||||
|
||||
// 1. Let finalList be a new list, initially empty.
|
||||
GC::RootVector<Value> final_list(vm.heap());
|
||||
|
||||
// 2. For each item of data:
|
||||
for (size_t i = 0; i < vm.argument_count(); ++i) {
|
||||
auto item = vm.argument(i);
|
||||
|
||||
// 1. Let converted be a DOM tree representation of item if possible; otherwise let converted be item with
|
||||
// optimally useful formatting applied.
|
||||
// FIXME: "Optimally-useful formatting"
|
||||
|
||||
// 2. Append converted to finalList.
|
||||
final_list.append(item);
|
||||
}
|
||||
|
||||
// 3. Perform Logger("dirxml", finalList).
|
||||
if (m_client) {
|
||||
return m_client->logger(LogLevel::DirXML, final_list);
|
||||
}
|
||||
|
||||
return js_undefined();
|
||||
}
|
||||
|
||||
static ThrowCompletionOr<String> label_or_fallback(VM& vm, StringView fallback)
|
||||
{
|
||||
return vm.argument_count() > 0 && !vm.argument(0).is_undefined()
|
||||
|
@ -850,7 +878,7 @@ ThrowCompletionOr<GC::RootVector<Value>> ConsoleClient::formatter(GC::RootVector
|
|||
}
|
||||
// 4. If specifier is %o, optionally let converted be current with optimally useful formatting applied.
|
||||
else if (specifier == "%o"sv) {
|
||||
// TODO: "Optimally-useful formatting"
|
||||
// FIXME: "Optimally-useful formatting"
|
||||
converted = current;
|
||||
}
|
||||
// 5. If specifier is %O, optionally let converted be current with generic JavaScript object formatting applied.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue