Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions src/components/tabs/js/tabsDummyWrapperDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,49 @@ angular
* @private
*
* @param $mdUtil
* @param $window
* @returns {{require: string, link: link}}
* @constructor
*
*
* @ngInject
*/
function MdTabsDummyWrapper ($mdUtil) {
function MdTabsDummyWrapper ($mdUtil, $window) {
return {
require: '^?mdTabs',
link: function link (scope, element, attr, ctrl) {
if (!ctrl) return;

var observer = new MutationObserver(function(mutations) {
var observer;
var disconnect;

var mutationCallback = function() {
ctrl.updatePagination();
ctrl.updateInkBarStyles();
});

var config = {
childList: true,
subtree: true,
// Per https://bugzilla.mozilla.org/show_bug.cgi?id=1138368, browsers will not fire
// the childList mutation, once a <span> element's innerText changes.
// The characterData of the <span> element will change.
characterData: true
};

observer.observe(element[0], config);
if('MutationObserver' in $window) {
var config = {
childList: true,
subtree: true,
// Per https://bugzilla.mozilla.org/show_bug.cgi?id=1138368, browsers will not fire
// the childList mutation, once a <span> element's innerText changes.
// The characterData of the <span> element will change.
characterData: true
};

observer = new MutationObserver(mutationCallback);
observer.observe(element[0], config);
disconnect = observer.disconnect.bind(observer);
} else {
var debounced = $mdUtil.debounce(mutationCallback, 15, null, false);

element.on('DOMSubtreeModified', debounced);
disconnect = element.off.bind(element, 'DOMSubtreeModified', debounced);
}

// Disconnect the observer
scope.$on('$destroy', function() {
if (observer) {
observer.disconnect();
}
disconnect();
});
}
};
Expand Down