mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: make sure default slot is applied
Before this commit, owl was erroneously defining default slots in most cases, even though they are empty. The problem occurs when the content of a component slots is a t-set-slot, and we remove that, then use the rest as default slots, even though it is only reduced to a set of text nodes. With this commit, we only consider the content as default content if it is not only a sequence of text nodes containing only spaces. closes #882
This commit is contained in:
@@ -452,12 +452,17 @@ QWeb.addDirective({
|
||||
}
|
||||
}
|
||||
if (clone.childNodes.length) {
|
||||
let hasContent = false;
|
||||
const t = clone.ownerDocument!.createElement("t");
|
||||
for (let child of Object.values(clone.childNodes)) {
|
||||
hasContent =
|
||||
hasContent || (child instanceof Text ? Boolean(child.textContent.trim().length) : true);
|
||||
t.appendChild(child);
|
||||
}
|
||||
const slotFn = qweb._compile(`slot_default_template`, { elem: t, hasParent: true });
|
||||
QWeb.slots[`${slotId}_default`] = slotFn;
|
||||
if (hasContent) {
|
||||
const slotFn = qweb._compile(`slot_default_template`, { elem: t, hasParent: true });
|
||||
QWeb.slots[`${slotId}_default`] = slotFn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user