Fix: Fixed ui.addition MutationObserver, only apply additions to inserted nodes.

This commit is contained in:
buddh4 2017-05-10 23:06:10 +02:00
parent 7aa591095b
commit c71ee9c966
2 changed files with 14 additions and 3 deletions

View File

@ -8,6 +8,7 @@ HumHub Change Log
- Enh: Added Registraion::EVENT_AFTER_REGISTRATION UserEvent
- Enh: Added grunt `migrate-up` and `migrate-create` task
- Enh: Added profile field type `CheckboxList`
- Fix: Fixed `ui.addition` `MutationObserver`, only apply additions to inserted nodes.
1.2.0 (April 16, 2017)
--------------------------------

View File

@ -253,10 +253,20 @@ humhub.module('ui.additions', function (module, require, $) {
options = {};
}
node = (node instanceof $) ? node[0] : node;
var $node = $(node);
node = $node[0];
var observer = new MutationObserver(function (mutations) {
module.applyTo(node);
mutations.forEach(function(mutation) {
var $nodes = $(mutation.addedNodes).filter(function () {
return this.nodeType === 1; // filter out text nodes
});
$nodes.each(function() {
var $this = $(this);
console.log('Apply additions to ', this);
module.applyTo($this);
})
});
});
observer.observe(node, {childList: true, subtree: true});