-
-
Save beckyconning/9fe5450046cabfa5d104 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
angular.module('issue-9128-patch', []) | |
.config(['$provide', function($provide){ | |
$provide.decorator('$rootScope', ['$delegate', function($rootScope) { | |
var _proto | |
, _new | |
, nextUid = function() { | |
return ++$rootScope.$id; | |
} | |
, Scope = function() { | |
this.$id = nextUid(); | |
this.$$phase = this.$parent = this.$$watchers = this.$$nextSibling = this.$$prevSibling = this.$$childHead = this.$$childTail = null; | |
this.$root = this; | |
this.$$destroyed = false; | |
this.$$listeners = {}; | |
this.$$listenerCount = {}; | |
this.$$isolateBindings = null; | |
}; | |
_proto = Object.create(Object.getPrototypeOf($rootScope)); | |
Scope.prototype = _proto; | |
_new = function(isolate, parent) { | |
var child; | |
parent = parent || this; | |
if (isolate) { | |
child = new Scope(); | |
child.$root = this.$root; | |
} else { | |
// Only create a child scope class if somebody asks for one, | |
// but cache it to allow the VM to optimize lookups. | |
if(!this.$$ChildScope) { | |
this.$$ChildScope = function ChildScope() { | |
this['$$watchers'] = this['$$nextSibling'] = this['$$childHead'] = this['$$childTail'] = null; | |
this['$$listeners'] = {}; | |
this['$$listenerCount'] = {}; | |
this['$id'] = nextUid(); | |
this['$$ChildScope'] = null; | |
}; | |
this['$$ChildScope'].prototype = this; | |
} | |
child = new this.$$ChildScope(); | |
} | |
child['$parent'] = parent; | |
child['$$prevSibling'] = parent.$$childTail; | |
if (parent.$$childHead) { | |
parent.$$childTail.$$nextSibling = child; | |
parent.$$childTail = child; | |
} else { | |
parent.$$childHead = parent.$$childTail = child; | |
} | |
// When the new scope is not isolated or we inherit from `this`, and | |
// the parent scope is destroyed, the property `$$destroyed` is inherited | |
// prototypically. In all other cases, this property needs to be set | |
// when the parent scope is destroyed. | |
// The listener needs to be added after the parent is set | |
if (isolate || parent != this) { | |
child.$on('$destroy', destroyChild); | |
} | |
return child; | |
function destroyChild() { | |
child.$$destroyed = true; | |
} | |
}; | |
$rootScope.$new = _new; | |
return $rootScope; | |
}]); | |
}]); |
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
{ | |
"name": "angular-issue-9128-patch", | |
"version": "0.0.3", | |
"authors": [ | |
"Jeff Hunken <[email protected]>" | |
], | |
"description": "Decorator patch to fix #9128", | |
"main": "angular-issue-9128-patch.js", | |
"keywords": [ | |
"angular", | |
"9128", | |
"issue", | |
"patch", | |
"readonly" | |
], | |
"license": "MIT", | |
"homepage": "https://gist.github.com/beckyconning/9fe5450046cabfa5d104", | |
"ignore": [ | |
"**/.*", | |
"node_modules", | |
"bower_components", | |
"test", | |
"tests" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there,
Nice bit of code, I need to try it to see if it fixes the issue for me on angular 1.4.7.
However, why not doing some user agent sniffing just to be sure that this code is only used/added when we are on iOS8 or something like that ? Because the webkit bug related to all of this is supposed to be fixed in iOS9...