mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
revert: refactor(mocks): simplify the inject implementation
This reverts commit 64d58a5b52.
For some weird reason this is causing regressions at Google.
I'm not sure why and I'm running out of time to investigate, so I'm taking
a safe route here and reverting the commit since it's just a refactoring.
This commit is contained in:
7
src/ngMock/angular-mocks.js
vendored
7
src/ngMock/angular-mocks.js
vendored
@@ -2095,7 +2095,7 @@ if(window.jasmine || window.mocha) {
|
||||
window.inject = angular.mock.inject = function() {
|
||||
var blockFns = Array.prototype.slice.call(arguments, 0);
|
||||
var errorForStack = new Error('Declaration Location');
|
||||
return isSpecRunning() ? workFn() : workFn;
|
||||
return isSpecRunning() ? workFn.call(currentSpec) : workFn;
|
||||
/////////////////////
|
||||
function workFn() {
|
||||
var modules = currentSpec.$modules || [];
|
||||
@@ -2108,8 +2108,9 @@ if(window.jasmine || window.mocha) {
|
||||
}
|
||||
for(var i = 0, ii = blockFns.length; i < ii; i++) {
|
||||
try {
|
||||
// jasmine sets this to be the current spec, so we are mimicing that
|
||||
injector.invoke(blockFns[i] || angular.noop, currentSpec);
|
||||
/* jshint -W040 *//* Jasmine explicitly provides a `this` object when calling functions */
|
||||
injector.invoke(blockFns[i] || angular.noop, this);
|
||||
/* jshint +W040 */
|
||||
} catch (e) {
|
||||
if (e.stack && errorForStack) {
|
||||
throw new ErrorAddingDeclarationLocationStack(e, errorForStack);
|
||||
|
||||
Reference in New Issue
Block a user