FIX: Don't call cooked decorators in composer if cooked is unchanged

FIX: Don’t call cooked decorators in composer if cooked is unchanged

If cooked is unchanged, ember will not re-render the preview area, so we should not re-run the post-processing decorators. This can cause issues when decorateCooked functions are not idempotent.

diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js
index 4917acc..f979d7c 100644
--- a/app/assets/javascripts/discourse/app/components/d-editor.js
+++ b/app/assets/javascripts/discourse/app/components/d-editor.js
@@ -367,6 +367,9 @@ export default Component.extend({
       if (this.isDestroyed) {
         return;
       }
+
+      if (this.preview === cooked) return;
+
       this.set("preview", cooked);
       schedule("afterRender", () => {
         if (this._state !== "inDOM") {

GitHub sha: 9e98c02d

1 Like