FIX: Make diffHTML handle external changes (#12821)

FIX: Make diffHTML handle external changes (#12821)

Changing the contents of the preview element between two uses of diff.innerHTML did not apply the diff correctly.

diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js
index 643934d..ae1a566 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,

GitHub sha: 2c417338

This commit appears in #12821 which was approved by eviltrout and ZogStriP. It was merged by nbianca.