[FIX] web: renderToElement should be detached
Before this commit, the element returned by the function renderToElement, it was still attached to the parent <div> added in the render function. Now, the element returned is detached. Part of task~3443861 Part-of: odoo/odoo#130467
This commit is contained in:
committed by
Samuel Degueldre
parent
e338487028
commit
f30be0732e
@@ -3,7 +3,9 @@
|
||||
import { blockDom, markup } from "@odoo/owl";
|
||||
|
||||
export function renderToElement(template, context = {}) {
|
||||
return render(template, context).firstElementChild;
|
||||
const el = render(template, context).firstElementChild;
|
||||
el?.remove();
|
||||
return el;
|
||||
}
|
||||
|
||||
export function renderToFragment(template, context = {}) {
|
||||
|
||||
@@ -16,6 +16,11 @@ QUnit.module("utils", () => {
|
||||
</t>`
|
||||
);
|
||||
const compiledTemplate = renderToElement("test.render.template.1");
|
||||
assert.strictEqual(
|
||||
compiledTemplate.parentElement,
|
||||
null,
|
||||
"compiledTemplate.parentElement must be empty"
|
||||
);
|
||||
assert.strictEqual(
|
||||
compiledTemplate.nodeType,
|
||||
Node.ELEMENT_NODE,
|
||||
|
||||
Reference in New Issue
Block a user