fix: patch onSidebarDragStart to strip trailing whitespace nodes and prevent DOM injection errors
This commit is contained in:
parent
bf48212bf3
commit
2ed12725fd
@ -116,5 +116,30 @@ patch(SignTemplateBody.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return [updatedSignItems, Id2UpdatedItem];
|
return [updatedSignItems, Id2UpdatedItem];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FIX: Odoo Core Bug where trailing whitespace on custom items causes target.lastChild to be a Text Node.
|
||||||
|
* This patch intercepts the insertAdjacentHTML during onSidebarDragStart to strip trailing whitespace nodes immediately,
|
||||||
|
* without modifying Odoo Enterprise source code.
|
||||||
|
*/
|
||||||
|
onSidebarDragStart(e) {
|
||||||
|
const firstPage = this.root.querySelector('.page[data-page-number="1"]');
|
||||||
|
if (firstPage && firstPage.insertAdjacentHTML) {
|
||||||
|
const originalInsert = firstPage.insertAdjacentHTML;
|
||||||
|
firstPage.insertAdjacentHTML = function(position, text) {
|
||||||
|
originalInsert.call(this, position, text.trim());
|
||||||
|
// Remove trailing whitespace nodes injected by QWeb
|
||||||
|
while (this.lastChild && this.lastChild.nodeType !== 1) { // 1 == ELEMENT_NODE
|
||||||
|
this.lastChild.remove();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return super.onSidebarDragStart(...arguments);
|
||||||
|
} finally {
|
||||||
|
firstPage.insertAdjacentHTML = originalInsert;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onSidebarDragStart(...arguments);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user