Odoo18-Base/addons/web/static/lib/hoot/mock/console.js
KaySar12 8a9c49514f
Some checks are pending
Setup Native Action / native (3.12.7) (push) Waiting to run
Setup Native Action / docker (3.12.7) (push) Waiting to run
update base web lib
2025-05-23 14:51:51 +07:00

38 lines
1.2 KiB
JavaScript

/** @odoo-module */
import { MockEventTarget } from "../hoot_utils";
//-----------------------------------------------------------------------------
// Global
//-----------------------------------------------------------------------------
const {
console,
Object: { entries: $entries },
} = globalThis;
//-----------------------------------------------------------------------------
// Internal
//-----------------------------------------------------------------------------
const DISPATCHING_METHODS = ["error", "trace", "warn"];
//-----------------------------------------------------------------------------
// Exports
//-----------------------------------------------------------------------------
export class MockConsole extends MockEventTarget {
static {
for (const [name, value] of $entries(console)) {
if (DISPATCHING_METHODS.includes(name)) {
this.prototype[name] = function (...args) {
this.dispatchEvent(new CustomEvent(name, { detail: args }));
return value.apply(this, arguments);
};
} else {
this.prototype[name] = value;
}
}
}
}