From 2c417338ed8d1188cc3ec22ecb07447ad4ce5d06 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Mon, 26 Apr 2021 14:28:08 +0300 Subject: [PATCH] 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. --- app/assets/javascripts/discourse/app/components/d-editor.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js index 643934d63e..ae1a5666b0 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,