mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Implement console.count/countReset (#31635)
* Implement console.count/countReset * Address review comment Signed-off-by: syvb <me@iter.ca> --------- Signed-off-by: syvb <me@iter.ca>
This commit is contained in:
parent
f98975bbbe
commit
d2dcb20bea
7 changed files with 46 additions and 72 deletions
|
@ -296,4 +296,21 @@ impl Console {
|
|||
pub fn GroupEnd(global: &GlobalScope) {
|
||||
global.pop_console_group();
|
||||
}
|
||||
|
||||
/// <https://console.spec.whatwg.org/#count>
|
||||
pub fn Count(global: &GlobalScope, label: DOMString) {
|
||||
let count = global.increment_console_count(&label);
|
||||
let message = DOMString::from(format!("{label}: {count}"));
|
||||
console_message(global, message, LogLevel::Log);
|
||||
}
|
||||
|
||||
/// <https://console.spec.whatwg.org/#countreset>
|
||||
pub fn CountReset(global: &GlobalScope, label: DOMString) {
|
||||
if global.reset_console_count(&label).is_err() {
|
||||
Self::internal_warn(
|
||||
global,
|
||||
DOMString::from(format!("Counter “{label}” doesn’t exist.")),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue