mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibJS+WebContent+Browser+js: Implement console.group() methods
This implements: - console.group() - console.groupCollapsed() - console.groupEnd() In the Browser, we use `<details>` for the groups, which is not actually implemented yet, so groups are always open. In the REPL, groups are non-interactive, but still indent any output. This looks weird since the console prompt and return values remain on the far left, but this matches what Node does so it's probably fine. :^) I expect `console.group()` is not used much outside of browsers.
This commit is contained in:
parent
ff5e07d718
commit
d702678d16
Notes:
sideshowbarker
2024-07-17 22:06:44 +09:00
Author: https://github.com/AtkinsSJ
Commit: d702678d16
Pull-request: https://github.com/SerenityOS/serenity/pull/11382
Reviewed-by: https://github.com/davidot ✅
10 changed files with 281 additions and 25 deletions
|
@ -32,6 +32,9 @@ void ConsoleObject::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.countReset, count_reset, 0, attr);
|
||||
define_native_function(vm.names.clear, clear, 0, attr);
|
||||
define_native_function(vm.names.assert, assert_, 0, attr);
|
||||
define_native_function(vm.names.group, group, 0, attr);
|
||||
define_native_function(vm.names.groupCollapsed, group_collapsed, 0, attr);
|
||||
define_native_function(vm.names.groupEnd, group_end, 0, attr);
|
||||
}
|
||||
|
||||
ConsoleObject::~ConsoleObject()
|
||||
|
@ -98,4 +101,22 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::assert_)
|
|||
return global_object.console().assert_();
|
||||
}
|
||||
|
||||
// 1.3.1. group(...data), https://console.spec.whatwg.org/#group
|
||||
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::group)
|
||||
{
|
||||
return global_object.console().group();
|
||||
}
|
||||
|
||||
// 1.3.2. groupCollapsed(...data), https://console.spec.whatwg.org/#groupcollapsed
|
||||
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::group_collapsed)
|
||||
{
|
||||
return global_object.console().group_collapsed();
|
||||
}
|
||||
|
||||
// 1.3.3. groupEnd(), https://console.spec.whatwg.org/#groupend
|
||||
JS_DEFINE_NATIVE_FUNCTION(ConsoleObject::group_end)
|
||||
{
|
||||
return global_object.console().group_end();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue