-
-
Save zourtney/dcd8914d68b31a4f1f39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.config(['$provide', function($provide) { | |
// Minification-safe hack. | |
var $$watchers = '$$watchers', | |
$$nextSibling = '$$nextSibling', | |
$$childHead = '$$childHead', | |
$$childTail = '$$childTail', | |
$$listeners = '$$listeners', | |
$$listenerCount = '$$listenerCount', | |
$id = '$id', | |
$$childScopeClass = '$$childScopeClass', | |
$parent = '$parent', | |
$$prevSibling = '$$prevSibling'; | |
$provide.decorator('$rootScope', ['$delegate', function($rootScope) { | |
var proto = Object.getPrototypeOf($rootScope); | |
function nextUid () { | |
return ++$rootScope.$id; | |
} | |
proto.$new = function(isolate) { | |
var child; | |
if (isolate) { | |
child = new proto.constructor(); | |
child.$root = this.$root; | |
// ensure that there is just one async queue per $rootScope and its children | |
child.$$asyncQueue = this.$$asyncQueue; | |
child.$$postDigestQueue = this.$$postDigestQueue; | |
} else { | |
// Only create a child scope class if somebody asks for one, | |
// but cache it to allow the VM to optimize lookups. | |
if (!this.$$childScopeClass) { | |
this.$$childScopeClass = function() { | |
this[$$watchers] = this[$$nextSibling] = | |
this[$$childHead] = this[$$childTail] = null; | |
this[$$listeners] = {}; | |
this[$$listenerCount] = {}; | |
this[$id] = nextUid(); | |
this[$$childScopeClass] = null; | |
}; | |
this.$$childScopeClass.prototype = this; | |
} | |
child = new this.$$childScopeClass(); | |
} | |
child['this'] = child; | |
child[$parent] = this; | |
child[$$prevSibling] = this.$$childTail; | |
if (this.$$childHead) { | |
this.$$childTail.$$nextSibling = child; | |
this.$$childTail = child; | |
} else { | |
this.$$childHead = this.$$childTail = child; | |
} | |
return child; | |
}; | |
$rootScope.$new = proto.$new; | |
return $rootScope; | |
}]); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this, has worked for me (from preliminary testing).