1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:27:35 +00:00

WebContent: Add $() and $$() functions to browser console

These are based on the ones in Firefox:

`$(selector, element = document)`:
    Equivalent to `element.querySelector(selector)`.

`$$(selector, element = document)`:
    Equivalent to `element.querySelectorAll(selector)`.
This commit is contained in:
Sam Atkins 2022-11-19 12:30:16 +00:00 committed by Linus Groh
parent c793beb0cc
commit 4ad1695c78
2 changed files with 63 additions and 0 deletions

View file

@ -42,6 +42,10 @@ private:
JS_DECLARE_NATIVE_FUNCTION($0_getter);
// $_, the value of the most recent expression entered into the console
JS_DECLARE_NATIVE_FUNCTION($__getter);
// $(selector, element), equivalent to `(element || document).querySelector(selector)`
JS_DECLARE_NATIVE_FUNCTION($_function);
// $$(selector, element), equivalent to `(element || document).querySelectorAll(selector)`
JS_DECLARE_NATIVE_FUNCTION($$_function);
Web::HTML::Window* m_window_object;
JS::Value m_most_recent_result { JS::js_undefined() };