|
1 |
| -/** @odoo-module **/ |
2 | 1 |
|
3 |
| -import { browser } from "@web/core/browser/browser"; |
4 |
| -import { mount, whenReady } from "@odoo/owl"; |
| 2 | +import { whenReady } from "@odoo/owl"; |
| 3 | +import { mountComponent } from "@web/env"; |
5 | 4 | import { Playground } from "./playground";
|
6 |
| -import { templates } from "@web/core/assets"; |
7 | 5 |
|
8 |
| -// Mount the Playground component when the document.body is ready |
9 |
| -whenReady( () => { |
10 |
| - mount(Playground, document.body, { templates, dev: true, name: "Owl Tutorial" }); |
11 |
| -}); |
12 |
| - |
13 |
| - |
14 |
| - |
15 |
| -/** |
16 |
| - * This code is iterating over the cause property of an error object to console.error a string |
17 |
| - * containing the stack trace of the error and any errors that caused it. |
18 |
| - * @param {Event} ev |
19 |
| - */ |
20 |
| -function logError(ev) { |
21 |
| - ev.preventDefault(); |
22 |
| - let error = ev ?.error || ev.reason; |
| 6 | +const config = { |
| 7 | + dev: true, |
| 8 | + name: "Owl Tutorial", |
| 9 | +}; |
23 | 10 |
|
24 |
| - if (error.seen) { |
25 |
| - // If an error causes the mount to crash, Owl will reject the mount promise and throw the |
26 |
| - // error. Therefore, this if statement prevents the same error from appearing twice. |
27 |
| - return; |
28 |
| - } |
29 |
| - error.seen = true; |
30 |
| - |
31 |
| - let errorMessage = error.stack; |
32 |
| - while (error.cause) { |
33 |
| - errorMessage += "\nCaused by: " |
34 |
| - errorMessage += error.cause.stack; |
35 |
| - error = error.cause; |
36 |
| - } |
37 |
| - console.error(errorMessage); |
38 |
| -} |
39 |
| - |
40 |
| -browser.addEventListener("error", (ev) => {logError(ev)}); |
41 |
| -browser.addEventListener("unhandledrejection", (ev) => {logError(ev)}); |
| 11 | +// Mount the Playground component when the document.body is ready |
| 12 | +whenReady(() => mountComponent(Playground, document.body, config)); |
0 commit comments