diff --git a/addons/mrp_subcontracting/__manifest__.py b/addons/mrp_subcontracting/__manifest__.py index c56b68c0be0..f4fc208421a 100644 --- a/addons/mrp_subcontracting/__manifest__.py +++ b/addons/mrp_subcontracting/__manifest__.py @@ -66,7 +66,6 @@ 'web/static/lib/luxon/luxon.js', 'web/static/lib/owl/owl.js', 'web/static/lib/owl/odoo_module.js', - 'web/static/src/libs/owl.js', 'web/static/lib/jquery/jquery.js', 'web/static/lib/jquery.ui/jquery-ui.js', 'web/static/lib/popper/popper.js', diff --git a/addons/point_of_sale/__manifest__.py b/addons/point_of_sale/__manifest__.py index 8d83037d964..7d0215cd321 100644 --- a/addons/point_of_sale/__manifest__.py +++ b/addons/point_of_sale/__manifest__.py @@ -155,7 +155,6 @@ ('include', 'point_of_sale._assets_pos'), # dependencies of web.tests_assets (in the web tests, these come from assets_backend) 'web/static/tests/patch_translations.js', - 'web/static/src/libs/owl.js', 'web/static/lib/jquery/jquery.js', 'web/static/src/legacy/js/**/*', ('remove', 'web/static/src/legacy/js/libs/**/*'), diff --git a/addons/point_of_sale/static/src/app/main.js b/addons/point_of_sale/static/src/app/main.js index d9b20ec18f2..426d0cea521 100644 --- a/addons/point_of_sale/static/src/app/main.js +++ b/addons/point_of_sale/static/src/app/main.js @@ -3,11 +3,10 @@ import { Chrome } from "@point_of_sale/app/pos_app"; import { Loader } from "@point_of_sale/app/loader/loader"; import { templates } from "@web/core/assets"; -import { App, mount, reactive, whenReady, Component } from "@odoo/owl"; +import { App, mount, reactive, whenReady } from "@odoo/owl"; import { _t } from "@web/core/l10n/translation"; import { hasTouch } from "@web/core/browser/feature_detection"; import { localization } from "@web/core/l10n/localization"; -import { renderToString } from "@web/core/utils/render"; import { makeEnv, startServices } from "@web/env"; import { session } from "@web/session"; @@ -26,17 +25,6 @@ whenReady(() => { isEnterprise: session.server_version_info.slice(-1)[0] === "e", }; - // Make a temporary app to be able to use renderToString method before the main app is available. - const renderToStringApp = new App(Component, { - name: "renderToString app", - templates, - dev: !!odoo.debug, - warnIfNoStaticProps: true, - translatableAttributes: ["data-tooltip"], - translateFn: _t, - }); - renderToString.app = renderToStringApp; - // setup environment const env = makeEnv(); await startServices(env); @@ -52,7 +40,6 @@ whenReady(() => { translateFn: _t, props: { disableLoader: () => (loader.isShown = false) }, }); - renderToString.app = app; const root = await app.mount(document.body); const classList = document.body.classList; if (localization.direction === "rtl") { diff --git a/addons/project/__manifest__.py b/addons/project/__manifest__.py index c97593dd679..62ff2b74796 100644 --- a/addons/project/__manifest__.py +++ b/addons/project/__manifest__.py @@ -116,7 +116,6 @@ 'web/static/lib/luxon/luxon.js', 'web/static/lib/owl/owl.js', 'web/static/lib/owl/odoo_module.js', - 'web/static/src/libs/owl.js', 'web/static/lib/jquery/jquery.js', 'web/static/lib/jquery.ui/jquery-ui.js', 'web/static/lib/popper/popper.js', diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 0d9bed8c369..7098b868776 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -200,7 +200,6 @@ This module provides the core of the Odoo Web Client. 'web/static/lib/owl/owl.js', 'web/static/lib/owl/odoo_module.js', - 'web/static/src/libs/owl.js', 'web/static/lib/jquery/jquery.js', 'web/static/lib/jquery.ui/jquery-ui.js', 'web/static/lib/popper/popper.js', @@ -363,7 +362,6 @@ This module provides the core of the Odoo Web Client. # libs 'web/static/lib/luxon/luxon.js', 'web/static/lib/owl/owl.js', - 'web/static/src/libs/owl.js', 'web/static/lib/owl/odoo_module.js', # core 'web/static/src/env.js', diff --git a/addons/web/static/src/core/utils/render.js b/addons/web/static/src/core/utils/render.js index 3a64c4cb377..dd752583848 100644 --- a/addons/web/static/src/core/utils/render.js +++ b/addons/web/static/src/core/utils/render.js @@ -1,14 +1,16 @@ /** @odoo-module **/ -import { blockDom, markup } from "@odoo/owl"; +import { App, blockDom, Component, markup } from "@odoo/owl"; +import { templates } from "@web/core/assets"; +import { _t } from "@web/core/l10n/translation"; export function renderToElement(template, context = {}) { const el = render(template, context).firstElementChild; if (el?.nextElementSibling) { throw new Error( `The rendered template '${template}' contains multiple root ` + - `nodes that will be ignored using renderToElement, you should ` + - `consider using renderToFragment or refactoring the template.` + `nodes that will be ignored using renderToElement, you should ` + + `consider using renderToFragment or refactoring the template.` ); } el?.remove(); @@ -33,12 +35,23 @@ export function renderToFragment(template, context = {}) { export function renderToString(template, context = {}) { return render(template, context).innerHTML; } +let app; +Object.defineProperty(renderToString, "app", { + get: () => { + if (!app) { + app = new App(Component, { + name: "renderToString", + templates, + translatableAttributes: ["data-tooltip"], + translateFn: _t, + }); + } + return app; + }, +}); function render(template, context = {}) { const app = renderToString.app; - if (!app) { - throw new Error("an app must be configured before using renderToString"); - } const templateFn = app.getTemplate(template); const bdom = templateFn(context, {}); const div = document.createElement("div"); diff --git a/addons/web/static/src/legacy/js/public/public_root.js b/addons/web/static/src/legacy/js/public/public_root.js index 2ed4223f86c..ef1fea6ef52 100644 --- a/addons/web/static/src/legacy/js/public/public_root.js +++ b/addons/web/static/src/legacy/js/public/public_root.js @@ -18,7 +18,6 @@ import { makeEnv, startServices } from "@web/env"; import { loadJS, templates } from '@web/core/assets'; import { MainComponentsContainer } from "@web/core/main_components_container"; import { browser } from '@web/core/browser/browser'; -import { renderToString } from "@web/core/utils/render"; import { _t } from "@web/core/l10n/translation"; import { App, Component, whenReady } from "@odoo/owl"; @@ -341,7 +340,6 @@ export async function createPublicRoot(RootWidget) { translateFn: _t, translatableAttributes: ["data-tooltip"], }); - renderToString.app = app; const language = lang || browser.navigator.language; const locale = language === "sr@latin" ? "sr-Latn-RS" : language.replace(/_/g, "-"); Settings.defaultLocale = locale; diff --git a/addons/web/static/src/libs/owl.js b/addons/web/static/src/libs/owl.js deleted file mode 100644 index 131665bcbac..00000000000 --- a/addons/web/static/src/libs/owl.js +++ /dev/null @@ -1,2 +0,0 @@ -/* eslint-disable no-undef */ -owl.App.validateTarget = () => {}; diff --git a/addons/web/static/src/start.js b/addons/web/static/src/start.js index f2a071bc422..ed82e73406b 100644 --- a/addons/web/static/src/start.js +++ b/addons/web/static/src/start.js @@ -5,7 +5,6 @@ import { legacySetupProm } from "./legacy/legacy_setup"; import { mapLegacyEnvToWowlEnv } from "./legacy/utils"; import { localization } from "@web/core/l10n/localization"; import { session } from "@web/session"; -import { renderToString } from "./core/utils/render"; import { templates } from "@web/core/assets"; import { hasTouch } from "@web/core/browser/feature_detection"; import { _t } from "@web/core/l10n/translation"; @@ -45,7 +44,6 @@ export async function startWebClient(Webclient) { translatableAttributes: ["data-tooltip"], translateFn: _t, }); - renderToString.app = app; const root = await app.mount(document.body); const classList = document.body.classList; if (localization.direction === "rtl") { diff --git a/addons/web/static/tests/legacy/helpers/test_env.js b/addons/web/static/tests/legacy/helpers/test_env.js index 8dd217384bc..685c45da816 100644 --- a/addons/web/static/tests/legacy/helpers/test_env.js +++ b/addons/web/static/tests/legacy/helpers/test_env.js @@ -2,7 +2,6 @@ import Bus from "@web/legacy/js/core/bus"; import { templates } from "@web/core/assets"; - import { renderToString } from "@web/core/utils/render"; import { App, Component } from "@odoo/owl"; let app; @@ -19,7 +18,6 @@ function makeTestEnvironment(env = {}, providedRPC = null) { if (!app) { app = new App(null, { templates, test: true }); - renderToString.app = app; } function rpc(route, params, options) { diff --git a/addons/web_editor/__manifest__.py b/addons/web_editor/__manifest__.py index 8c2f3a99c28..c2050c59bf9 100644 --- a/addons/web_editor/__manifest__.py +++ b/addons/web_editor/__manifest__.py @@ -55,7 +55,6 @@ Odoo Web Editor widget. 'web/static/lib/luxon/luxon.js', 'web/static/lib/owl/owl.js', 'web/static/lib/owl/odoo_module.js', - 'web/static/src/libs/owl.js', 'web/static/lib/jquery/jquery.js', 'web/static/lib/jquery.ui/jquery-ui.js', 'web/static/lib/popper/popper.js', diff --git a/addons/website_slides/__manifest__.py b/addons/website_slides/__manifest__.py index d9026a5493b..25b4f7813df 100644 --- a/addons/website_slides/__manifest__.py +++ b/addons/website_slides/__manifest__.py @@ -155,7 +155,6 @@ Featuring 'web/static/lib/luxon/luxon.js', 'web/static/lib/owl/owl.js', 'web/static/lib/owl/odoo_module.js', - 'web/static/src/libs/owl.js', 'web/static/lib/jquery/jquery.js', 'web/static/lib/jquery.ui/jquery-ui.js', 'web/static/lib/popper/popper.js',