Fixed DOM mutation detection
authorAlexander Ebert <ebert@woltlab.com>
Mon, 13 Feb 2017 10:33:22 +0000 (11:33 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 13 Feb 2017 10:33:22 +0000 (11:33 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabEvent.js

index e8b78185991457d8f6541684ba95deda9966e9ae..601722dce36da1675ef948346d98af6562884251 100644 (file)
@@ -35,6 +35,32 @@ $.Redactor.prototype.WoltLabEvent = function() {
                                        }, 100);
                                });
                        }
+                       
+                       this.events.iterateObserver = (function(mutation) {
+                               var stop = false;
+                               
+                               // target
+                               // WoltLab modification: do not suppress event if nodes have been added
+                               if (((this.opts.type === 'textarea' || this.opts.type === 'div')
+                                       && (!this.detect.isFirefox() && mutation.target === this.core.editor()[0]) && (mutation.type === 'childList' && !mutation.addedNodes.length))
+                                       || (mutation.attributeName === 'class' && mutation.target === this.core.editor()[0])
+                               )
+                               {
+                                       console.log(mutation, mutation.addedNodes.length);
+                                       stop = true;
+                               }
+                               
+                               if (!stop)
+                               {
+                                       this.observe.load();
+                                       this.events.changeHandler();
+                               }
+                       }).bind(this);
+                       
+                       // re-attach the observer
+                       this.events.observer.disconnect();
+                       this.events.createObserver();
+                       this.events.setupObserver();
                },
                
                _setEvents: function(EventHandler) {