fix: patch PDFIframe to strip trailing whitespace nodes during sign item rendering
This commit is contained in:
parent
15802feeee
commit
016a441d32
@ -213,3 +213,29 @@ patch(SignablePDFIframe.prototype, {
|
||||
return super.getSignatureValueFromElement(...arguments);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* FIX: Odoo Core Bug where trailing whitespace on custom items causes target.lastChild to be a Text Node.
|
||||
* This patch intercepts the insertAdjacentHTML during renderSignItem to strip trailing whitespace nodes immediately,
|
||||
* without modifying Odoo Enterprise source code.
|
||||
*/
|
||||
patch(PDFIframe.prototype, {
|
||||
renderSignItem(signItemData, target) {
|
||||
if (target && target.insertAdjacentHTML) {
|
||||
const originalInsert = target.insertAdjacentHTML;
|
||||
target.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.renderSignItem(...arguments);
|
||||
} finally {
|
||||
target.insertAdjacentHTML = originalInsert;
|
||||
}
|
||||
}
|
||||
return super.renderSignItem(...arguments);
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user