angular-materialize
angular-materialize copied to clipboard
Directive ngModel inside ui.materialize.ngModel module may affect the performance of whole application
In my app I used this library. When I profiled with chrome devtools, it showed 30% of the cpu time was taken by the code given below.
$timeout(function() {
// To stop an infinite feedback-loop with material multiple-select.
if (value instanceof Array && oldValue instanceof Array) {
if (value.length == oldValue.length) {
return;
}
}
if (element.is('select')) {
return;
}
// This fix is mainly to get placeholders to appear correctly, and it apparently screws things for the selects, so only doing this on something that isn't a select.
if (value) {
element.trigger("change");
} else if (element.attr('placeholder') === undefined) {
if (!element.is(":focus"))
element.trigger("blur");
}
});
Apparently this has been added to fix a bug in multiple-select. Better if we find another approach as this affects the performance.
I agree, it is kind of an ugly fix. But the functionality is needed, so any change must preserve the current functionality. Pull requests are welcome.