Skip to content

Instantly share code, notes, and snippets.

@dhyegocalota
Forked from johgusta/decorator
Created September 30, 2015 12:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhyegocalota/c6e5c3f736bf4a94ef64 to your computer and use it in GitHub Desktop.
Save dhyegocalota/c6e5c3f736bf4a94ef64 to your computer and use it in GitHub Desktop.
Disable JIT compiler on Safari for $new
angular.module('lib.decorators', [])
.config(['$provide', function($provide){
'use strict';
var isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
if(isSafari) {
$provide.decorator('$rootScope', ['$delegate', function($rootScope) {
var scopePrototype = Object.getPrototypeOf($rootScope);
var originalScopeNew = scopePrototype.$new;
scopePrototype.$new = function () {
try {
return originalScopeNew.apply(this, arguments);
} catch(e) {
console.error(e);
throw e;
}
};
return $rootScope;
}]);
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment