function subscribeToTitle(getTitle, setTitle) {
    var titleElement = document.querySelector('title');
    var docEl = document.documentElement;

    function titleModified() {
        var title = document.title;
        var oldTitle = getTitle();
        if (oldTitle !== title) {
            setTitle(title);
        }
    }

    function subscribeAsObserver() {
        var observer = new MutationObserver(function () {
            titleModified();
        });
        observer.observe(titleElement, { childList: true });
        return function () {
            return observer.disconnect();
        };
    }

    function subscribeIE() {
        // eslint-disable-next-line
        document.onpropertychange = function () {
            if (window.event.propertyName == 'title') {
                titleModified();
            }
        };
        // eslint-disable-next-line
        return function () {
            return document.onpropertychange = undefined;
        };
    }

    function subscribeAsModification() {
        var type = 'DOMSubtreeModified';
        var listener = function listener(evt) {
            var t = evt.target;
            // eslint-disable-next-line
            if (t === titleElement || t.parentNode && t.parentNode === titleElement) {
                titleModified();
            }
        };
        docEl.addEventListener(type, listener, false);
        return function () {
            return docEl.removeEventListener(type, listener, false);
        };
    }

    if (docEl && docEl.addEventListener) {
        return subscribeAsModification();
        // stangely does not work in chrome when started over karma
    } else if (typeof MutationObserver !== 'undefined') {
        return subscribeAsObserver();
    } else {
        return subscribeIE();
    }
}
function subscribeToTitle(getTitle, setTitle) {
    var titleElement = document.querySelector('title');
    var docEl = document.documentElement;

    function titleModified() {
        var title = document.title;
        var oldTitle = getTitle();
        if (oldTitle !== title) {
            setTitle(title);
        }
    }

    function subscribeAsObserver() {
        var observer = new MutationObserver(function () {
            titleModified();
        });
        observer.observe(titleElement, { childList: true });
        return function () {
            return observer.disconnect();
        };
    }

    function subscribeIE() {
        
        document.onpropertychange = function () {
            if (window.event.propertyName == 'title') {
                titleModified();
            }
        };
        
        return function () {
            return document.onpropertychange = undefined;
        };
    }

    function subscribeAsModification() {
        var type = 'DOMSubtreeModified';
        var listener = function listener(evt) {
            var t = evt.target;
            
            if (t === titleElement || t.parentNode && t.parentNode === titleElement) {
                titleModified();
            }
        };
        docEl.addEventListener(type, listener, false);
        return function () {
            return docEl.removeEventListener(type, listener, false);
        };
    }

    if (docEl && docEl.addEventListener) {
        return subscribeAsModification();
        
    } else if (typeof MutationObserver !== 'undefined') {
        return subscribeAsObserver();
    } else {
        return subscribeIE();
    }
}
function subscribeToTitle ( getTitle , setTitle ) { var titleElement = document . querySelector ( 'title' ) ; var docEl = document . documentElement ; function titleModified ( ) { var title = document . title ; var oldTitle = getTitle ( ) ; if ( oldTitle !== title ) { setTitle ( title ) ; } } function subscribeAsObserver ( ) { var observer = new MutationObserver ( function ( ) { titleModified ( ) ; } ) ; observer . observe ( titleElement , { childList : true } ) ; return function ( ) { return observer . disconnect ( ) ; } ; } function subscribeIE ( ) { // eslint-disable-next-line document . onpropertychange = function ( ) { if ( window . event . propertyName == 'title' ) { titleModified ( ) ; } } ; // eslint-disable-next-line return function ( ) { return document . onpropertychange = undefined ; } ; } function subscribeAsModification ( ) { var type = 'DOMSubtreeModified' ; var listener = function listener ( evt ) { var t = evt . target ; // eslint-disable-next-line if ( t === titleElement || t . parentNode && t . parentNode === titleElement ) { titleModified ( ) ; } } ; docEl . addEventListener ( type , listener , false ) ; return function ( ) { return docEl . removeEventListener ( type , listener , false ) ; } ; } if ( docEl && docEl . addEventListener ) { return subscribeAsModification ( ) ; // stangely does not work in chrome when started over karma } else if ( typeof MutationObserver !== 'undefined' ) { return subscribeAsObserver ( ) ; } else { return subscribeIE ( ) ; } }
http://stackoverflow.com/questions/2497200/how-to-listen-for-changes-to-the-title-element https://developer.mozilla.org/en/docs/Web/API/MutationObserver http://caniuse.com/#feat=mutationobserver https://msdn.microsoft.com/en-us/library/ms536956(v=vs.85).aspx
http : // stackoverflow . com / questions / 2497200 / how - to - listen - for - changes - to - the - title - element https : // developer . mozilla . org / en / docs / Web / API / MutationObserver http : // caniuse . com / #feat = mutationobserver https : // msdn . microsoft . com / en - us / library / ms536956 ( v = vs . 85 ) . aspx