Skip to content

Commit dab69ec

Browse files
committed
Change concat step to order files correctly (see angular-ui#49)
1 parent c85f721 commit dab69ec

File tree

4 files changed

+43
-17
lines changed

4 files changed

+43
-17
lines changed

grunt.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ module.exports = function (grunt) {
1717
},
1818
concat: {
1919
build: {
20-
src: ['<banner:meta.banner>', '<banner:meta.prefix>', 'src/*.js', '<banner:meta.suffix>' ],
20+
src: [
21+
'<banner:meta.banner>',
22+
'<banner:meta.prefix>',
23+
'src/common.js',
24+
'src/templateFactory.js',
25+
'src/urlMatcherFactory.js',
26+
'src/urlRouter.js',
27+
'src/state.js',
28+
'src/viewDirective.js',
29+
'src/compat.js',
30+
'<banner:meta.suffix>'
31+
],
2132
dest: '<%= builddir %>/<%= pkg.name %>.js'
2233
}
2334
},
@@ -28,15 +39,15 @@ module.exports = function (grunt) {
2839
}
2940
},
3041
lint: {
31-
files: ['grunt.js', 'src/*.js']
42+
files: ['grunt.js', 'src/*.js', '<%= builddir %>/<%= pkg.name %>.js']
3243
},
3344
jshint: {
3445
options: {
3546
eqnull: true
3647
}
3748
},
3849
watch: {
39-
files: ['src/*.js', 'test/*.js'],
50+
files: ['src/*.js', 'test/**/*.js'],
4051
tasks: 'build test'
4152
}
4253
});

src/compat.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ function $RouteProvider( $stateProvider, $urlRouterProvider) {
55

66
onEnterRoute.$inject = ['$$state'];
77
function onEnterRoute( $$state) {
8+
/*jshint validthis: true */
89
this.locals = $$state.locals.globals;
910
}
1011

1112
function onExitRoute() {
13+
/*jshint validthis: true */
1214
this.locals = null;
1315
}
1416

1517
this.when = when;
1618
function when(url, route) {
19+
/*jshint validthis: true */
1720
if (route.redirectTo != null) {
1821
// Redirect, configure directly on $urlRouterProvider
1922
var redirect = route.redirectTo, handler;
@@ -59,8 +62,6 @@ function $RouteParamsProvider() {
5962
}
6063
}
6164

62-
var $ViewDirective; // forward reference
6365
angular.module('ui.compat')
64-
.directive('ngView', $ViewDirective)
65-
.provider('$route', $RouteProvider)
66-
.provider('$routeParams', $RouteParamsProvider);
66+
.provider('$route', $RouteProvider)
67+
.directive('ngView', $ViewDirective);

src/state.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
130130
// .state(name, state)
131131
this.state = state;
132132
function state(name, definition) {
133+
/*jshint validthis: true */
133134
if (isObject(name)) definition = name;
134135
else definition.name = name;
135136
registerState(definition);
@@ -141,6 +142,9 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
141142
$get.$inject = ['$rootScope', '$q', '$templateFactory', '$injector', '$stateParams', '$location', '$urlRouter'];
142143
function $get( $rootScope, $q, $templateFactory, $injector, $stateParams, $location, $urlRouter) {
143144

145+
var TransitionSuperseded = $q.reject(new Error('transition superseded'));
146+
var TransitionPrevented = $q.reject(new Error('transition prevented'));
147+
144148
$state = {
145149
params: {},
146150
current: root.self,
@@ -157,14 +161,13 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
157161
}
158162
};
159163

160-
var TransitionSuperseded = $q.reject(new Error('transition superseded'));
161-
var TransitionPrevented = $q.reject(new Error('transition prevented'));
162-
163164
function transitionTo(to, toParams, updateLocation) {
164165
if (!isDefined(updateLocation)) updateLocation = true;
165166

166-
to = findState(to); if (to.abstract) throw new Error("Cannot transition to abstract state '" + to + "'");
167-
var toPath = to.path, from = $state.$current, fromParams = $state.params, fromPath = from.path;
167+
to = findState(to);
168+
if (to.abstract) throw new Error("Cannot transition to abstract state '" + to + "'");
169+
var toPath = to.path,
170+
from = $state.$current, fromParams = $state.params, fromPath = from.path;
168171

169172
// Starting from the root of the path, keep all levels that haven't changed
170173
var keep, state, locals = root.locals, toLocals = [];
@@ -183,7 +186,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
183186
return $q.when($state.current);
184187
}
185188

186-
// Normalize parameters before we pass them to event handlers etc.
189+
// Normalize/filter parameters before we pass them to event handlers etc.
187190
var normalizedToParams = {};
188191
forEach(to.params, function (name) {
189192
var value = toParams[name];
@@ -227,7 +230,6 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
227230
}
228231

229232
// Enter 'to' states not kept
230-
// TODO: Should we be invoking onEnter in a separate pass after we've updated $state and $location?
231233
for (l=keep; l<toPath.length; l++) {
232234
entering = toPath[l];
233235
entering.locals = toLocals[l];
@@ -239,7 +241,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
239241
// Update globals in $state
240242
$state.$current = to;
241243
$state.current = to.self;
242-
$state.params = toParams
244+
$state.params = toParams;
243245
copy($state.params, $stateParams);
244246
$state.transition = null;
245247

@@ -287,7 +289,9 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
287289
function resolve(deps, dst) {
288290
forEach(deps, function (value, key) {
289291
promises.push($q
290-
.when(isString(value) ? $injector.get(value) : $injector.invoke(value, state.self, locals))
292+
.when(isString(value) ?
293+
$injector.get(value) :
294+
$injector.invoke(value, state.self, locals))
291295
.then(function (result) {
292296
dst[key] = result;
293297
}));

test/test-config.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,18 @@ files = [
1010
'lib/angular-1.0.4.js',
1111
'test/lib/angular-mocks-1.0.4.js',
1212
'test/testUtils.js',
13-
'src/*.js',
13+
14+
'src/common.js',
15+
'src/templateFactory.js',
16+
'src/urlMatcherFactory.js',
17+
'src/urlRouter.js',
18+
'src/state.js',
19+
'src/viewDirective.js',
20+
'src/compat.js',
21+
1422
'test/*Spec.js',
23+
// 'test/compat/matchers.js',
24+
// 'test/compat/*Spec.js',
1525
];
1626

1727
// list of files to exclude

0 commit comments

Comments
 (0)