Skip to content

A platform for community discussion. Free, open, simple.

FIX: Make diffHTML handle external changes (#12821)

Bianca Nenciu2c417338ed8d
diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js
index 643934d63e8..ae1a5666b00 100644
--- a/app/assets/javascripts/discourse/app/components/d-editor.js
+++ b/app/assets/javascripts/discourse/app/components/d-editor.js
@@ -422,6 +422,9 @@ export default Component.extend({
);
loadScript("/javascripts/diffhtml.min.js").then(() => {
+ // changing the contents of the preview element between two uses of
+ // diff.innerHTML did not apply the diff correctly
+ window.diff.release(this.element.querySelector(".d-editor-preview"));
window.diff.innerHTML(
this.element.querySelector(".d-editor-preview"),
cookedElement.innerHTML,