Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit adcffe7

Browse files
author
Simon Tsvilik
committed
Merge branch 'master' of https://github.com/angular/angular.js
2 parents edd3682 + 5e45fd4 commit adcffe7

File tree

16 files changed

+133
-57
lines changed

16 files changed

+133
-57
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- 0.8
3+
- 0.10
44

55
env:
66
global:

Gruntfile.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ module.exports = function(grunt) {
3131
stream: true
3232
},
3333
tasks: [
34+
{grunt: true, args: ['test:docgen']},
3435
util.parallelTask('tests:docs'),
3536
util.parallelTask('tests:modules'),
3637
util.parallelTask('tests:jquery'),
3738
util.parallelTask('tests:jqlite'),
38-
util.parallelTask('tests:end2end')
39+
util.parallelTask('test:e2e')
3940
]
4041
}
4142
},
@@ -61,6 +62,11 @@ module.exports = function(grunt) {
6162
},
6263
testserver: {
6364
options: {
65+
// We use end2end task (which does not start the webserver)
66+
// and start the webserver as a separate process (in travis_build.sh)
67+
// to avoid https://github.com/joyent/libuv/issues/826
68+
port: 8000,
69+
hostname: '0.0.0.0',
6470
middleware: function(connect, options){
6571
return [
6672
function(req, resp, next) {

docs/component-spec/annotationsSpec.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ describe('Docs Annotations', function() {
6565

6666
describe('foldout directive', function() {
6767

68-
var $scope, parent, element, url, window;
68+
var $scope, parent, element, url;
6969
beforeEach(function() {
7070
module(function($provide, $animateProvider) {
71-
$provide.value('$window', window = angular.mock.createMockWindow());
7271
$animateProvider.register('.foldout', function($timeout) {
7372
return {
7473
enter : function(element, done) {
@@ -158,17 +157,13 @@ describe('Docs Annotations', function() {
158157

159158
describe('DocsController fold', function() {
160159

161-
var window, $scope, ctrl;
160+
var $scope, ctrl;
162161
beforeEach(function() {
163-
module(function($provide, $animateProvider) {
164-
$provide.value('$window', window = angular.mock.createMockWindow());
165-
});
166162
inject(function($rootScope, $controller, $location, $cookies, sections) {
167163
$scope = $rootScope.$new();
168164
ctrl = $controller('DocsController',{
169165
$scope : $scope,
170166
$location : $location,
171-
$window : window,
172167
$cookies : $cookies,
173168
sections : sections
174169
});

docs/component-spec/mocks.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var createMockWindow = function() {
2+
var mockWindow = {};
3+
var setTimeoutQueue = [];
4+
5+
mockWindow.location = window.location;
6+
mockWindow.document = window.document;
7+
mockWindow.getComputedStyle = angular.bind(window, window.getComputedStyle);
8+
mockWindow.scrollTo = angular.bind(window, window.scrollTo);
9+
mockWindow.navigator = window.navigator;
10+
mockWindow.setTimeout = function(fn, delay) {
11+
setTimeoutQueue.push({fn: fn, delay: delay});
12+
};
13+
mockWindow.setTimeout.queue = setTimeoutQueue;
14+
mockWindow.setTimeout.expect = function(delay) {
15+
if (setTimeoutQueue.length > 0) {
16+
return {
17+
process: function() {
18+
var tick = setTimeoutQueue.shift();
19+
expect(tick.delay).toEqual(delay);
20+
tick.fn();
21+
}
22+
};
23+
} else {
24+
expect('SetTimoutQueue empty. Expecting delay of ').toEqual(delay);
25+
}
26+
};
27+
28+
return mockWindow;
29+
};

docs/component-spec/versionJumpSpec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('DocsApp', function() {
2222
'1.1.4',
2323
'2.1.3'
2424
]);
25-
$provide.value('$window', window = angular.mock.createMockWindow());
25+
$provide.value('$window', window = createMockWindow());
2626
});
2727
inject(function($controller, $rootScope) {
2828
$scope = $rootScope.$new();
@@ -84,7 +84,7 @@ describe('DocsApp', function() {
8484

8585
$scope.jumpToDocsVersion('2.1.3');
8686
expect(window.location).toBe('http://code.angularjs.org/2.1.3/docs');
87-
});
87+
});
8888

8989
it('should jump to the older versions of current docs for version >= 1.0.2', function() {
9090
$scope.jumpToDocsVersion('1.0.1');

docs/content/tutorial/index.ngdoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ and follow the instructions for setting up your computer.
6464
<pre>npm install -g karma</pre>
6565
<li><p>You'll also need Git, which you can get from
6666
<a href="http://git-scm.com/download">the Git site</a>.</p></li>
67-
<li><p>Clone the angular-phonecat repository located at <a
68-
href="https://github.com/angular/angular-phonecat">Github</a> by running the following command:</p>
67+
<li><p>Clone the angular-phonecat repository located at
68+
<a href="https://github.com/angular/angular-phonecat">Github</a> by running the following command:</p>
6969
<pre>git clone git://github.com/angular/angular-phonecat.git</pre>
7070
<p>This command creates the <code>angular-phonecat</code> directory in your current
7171
directory.</p></li>

docs/src/ngdoc.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ exports.merge = merge;
3939
exports.Doc = Doc;
4040

4141
exports.ngVersions = function() {
42-
var line, versions = [], regex = /^v([1-9]\d*(?:\.\d+)+)$/; //only fetch >= 1.0.0 versions
42+
var versions = [], regex = /^v([1-9]\d*(?:\.\d+\S+)+)$/; //only fetch >= 1.0.0 versions
4343
shell.exec('git tag', {silent: true}).output.split(/\s*\n\s*/)
4444
.forEach(function(line) {
4545
var matches = regex.exec(line);
4646
if(matches && matches.length > 0) {
4747
versions.push(matches[1]);
4848
}
4949
});
50-
versions.push(exports.ngCurrentVersion().number);
50+
versions.push(exports.ngCurrentVersion().full);
5151
return versions;
5252
};
5353

@@ -295,7 +295,7 @@ Doc.prototype = {
295295
}
296296
pageClassName = pageClassName || prepareClassName(this.name || 'docs') + suffix;
297297

298-
text = '<div class="' + pageClassName + '">' +
298+
text = '<div class="' + pageClassName + '">' +
299299
marked(text) +
300300
'</div>';
301301
text = text.replace(/(?:<p>)?(REPLACEME\d+)(?:<\/p>)?/g, function(_, id) {
@@ -318,8 +318,8 @@ Doc.prototype = {
318318
text = content;
319319
}
320320
return "\n" + line.replace(pattern, function(match) {
321-
return '<div class="nocode nocode-content" data-popover ' +
322-
'data-content="' + text + '" ' +
321+
return '<div class="nocode nocode-content" data-popover ' +
322+
'data-content="' + text + '" ' +
323323
'data-title="' + title + '">' +
324324
match +
325325
'</div>';

docs/src/templates/js/docs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var docsApp = {
44
serviceFactory: {}
55
};
66

7-
docsApp.controller.DocsVersionsCtrl = ['$scope', '$window', 'NG_VERSIONS', function($scope, $window, NG_VERSIONS) {
7+
docsApp.controller.DocsVersionsCtrl = ['$scope', '$window', 'NG_VERSIONS', 'NG_VERSION', function($scope, $window, NG_VERSIONS, NG_VERSION) {
88
$scope.versions = expandVersions(NG_VERSIONS);
9-
$scope.version = ($scope.version || angular.version.full).match(/^([\d\.]+\d+)/)[1]; //match only the number
9+
$scope.version = ($scope.version || NG_VERSION).match(/^([\d\.]+\d+\S+)/)[1]; //match only the number
1010

1111
$scope.jumpToDocsVersion = function(value) {
1212
var isLastStable,

lib/grunt/utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ var version;
77
module.exports = {
88

99
init: function() {
10-
shell.exec('npm install');
10+
if (!process.env.TRAVIS) {
11+
shell.exec('npm install');
12+
}
1113
},
1214

1315

@@ -20,9 +22,7 @@ module.exports = {
2022
var hash = shell.exec('git rev-parse --short HEAD', {silent: true}).output.replace('\n', '');
2123

2224
var fullVersion = (match[1] + (match[2] ? '-' + hash : ''));
23-
var numVersion = semver[0] + '.' + semver[1] + '.' + semver[2];
2425
version = {
25-
number: numVersion,
2626
full: fullVersion,
2727
major: semver[0],
2828
minor: semver[1],

lib/sauce/sauce_connect_setup.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,17 @@ unzip $CONNECT_DOWNLOAD
2525
rm $CONNECT_DOWNLOAD
2626

2727

28+
29+
ARGS=""
30+
31+
# Set tunnel-id only on Travis, to make local testing easier.
32+
if [ ! -z "$TRAVIS_JOB_NUMBER" ]; then
33+
ARGS="$ARGS --tunnel-identifier $TRAVIS_JOB_NUMBER"
34+
fi
35+
if [ ! -z "$SAUCE_CONNECT_READY_FILE" ]; then
36+
ARGS="$ARGS --readyfile $SAUCE_CONNECT_READY_FILE"
37+
fi
38+
2839
echo "Starting Sauce Connect in the background"
2940
echo "Logging into $CONNECT_LOG"
30-
java -jar Sauce-Connect.jar --readyfile $SAUCE_CONNECT_READY_FILE \
31-
--tunnel-identifier $TRAVIS_JOB_NUMBER \
32-
$SAUCE_USERNAME $SAUCE_ACCESS_KEY > $CONNECT_LOG &
41+
java -jar Sauce-Connect.jar $ARGS $SAUCE_USERNAME $SAUCE_ACCESS_KEY > $CONNECT_LOG &

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
"q-fs": "0.1.36",
1616
"qq": "0.3.5",
1717
"shelljs": "0.1.2",
18-
"karma": "~0.9.4",
19-
"karma-jasmine": "~0.0.1",
20-
"karma-chrome-launcher": "~0.0.2",
21-
"karma-firefox-launcher": "~0.0.1",
22-
"karma-ng-scenario": "~0.0.1",
23-
"karma-junit-reporter": "~0.0.1",
24-
"karma-sauce-launcher": "~0.0.4",
25-
"karma-script-launcher": "~0.0.1",
18+
"karma": "~0.10",
19+
"karma-jasmine": "~0.1",
20+
"karma-chrome-launcher": "~0.1",
21+
"karma-firefox-launcher": "~0.1",
22+
"karma-ng-scenario": "~0.1",
23+
"karma-junit-reporter": "~0.1",
24+
"karma-sauce-launcher": "~0.1",
25+
"karma-script-launcher": "~0.1",
2626
"yaml-js": "0.0.5",
2727
"marked": "~0.2.9",
2828
"rewire": "1.1.3",

src/ng/filter/orderBy.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ function orderByFilter($parse){
125125
var t1 = typeof v1;
126126
var t2 = typeof v2;
127127
if (t1 == t2) {
128-
if (t1 == "string") v1 = v1.toLowerCase();
129-
if (t1 == "string") v2 = v2.toLowerCase();
128+
if (t1 == "string") {
129+
v1 = v1.toLowerCase();
130+
v2 = v2.toLowerCase();
131+
}
130132
if (v1 === v2) return 0;
131133
return v1 < v2 ? -1 : 1;
132134
} else {

src/ng/http.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ function $HttpProvider() {
412412
* return function(promise) {
413413
* return promise.then(function(response) {
414414
* // do something on success
415+
* return response;
415416
* }, function(response) {
416417
* // do something on error
417418
* if (canRecover(response)) {

src/ng/timeout.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,15 @@ function $TimeoutProvider() {
4545
deferred.reject(e);
4646
$exceptionHandler(e);
4747
}
48+
finally {
49+
delete deferreds[promise.$$timeoutId];
50+
}
4851

4952
if (!skipApply) $rootScope.$apply();
5053
}, delay);
5154

52-
cleanup = function() {
53-
delete deferreds[promise.$$timeoutId];
54-
};
55-
5655
promise.$$timeoutId = timeoutId;
5756
deferreds[timeoutId] = deferred;
58-
promise.then(cleanup, cleanup);
5957

6058
return promise;
6159
}
@@ -77,6 +75,7 @@ function $TimeoutProvider() {
7775
timeout.cancel = function(promise) {
7876
if (promise && promise.$$timeoutId in deferreds) {
7977
deferreds[promise.$$timeoutId].reject('canceled');
78+
delete deferreds[promise.$$timeoutId];
8079
return $browser.defer.cancel(promise.$$timeoutId);
8180
}
8281
return false;

test/ng/timeoutSpec.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,27 @@ describe('$timeout', function() {
6868
}));
6969

7070

71+
it('should forget references to deferreds when callback called even if skipApply is true',
72+
inject(function($timeout, $browser) {
73+
// $browser.defer.cancel is only called on cancel if the deferred object is still referenced
74+
var cancelSpy = spyOn($browser.defer, 'cancel').andCallThrough();
75+
76+
var promise1 = $timeout(function() {}, 0, false);
77+
var promise2 = $timeout(function() {}, 100, false);
78+
expect(cancelSpy).not.toHaveBeenCalled();
79+
80+
$timeout.flushNext(0);
81+
82+
// Promise1 deferred object should already be removed from the list and not cancellable
83+
$timeout.cancel(promise1);
84+
expect(cancelSpy).not.toHaveBeenCalled();
85+
86+
// Promise2 deferred object should not have been called and should be cancellable
87+
$timeout.cancel(promise2);
88+
expect(cancelSpy).toHaveBeenCalled();
89+
}));
90+
91+
7192
describe('exception handling', function() {
7293

7394
beforeEach(module(function($exceptionHandlerProvider) {
@@ -106,6 +127,20 @@ describe('$timeout', function() {
106127

107128
expect(log).toEqual('error: Some Error');
108129
}));
130+
131+
132+
it('should forget references to relevant deferred even when exception is thrown',
133+
inject(function($timeout, $browser) {
134+
// $browser.defer.cancel is only called on cancel if the deferred object is still referenced
135+
var cancelSpy = spyOn($browser.defer, 'cancel').andCallThrough();
136+
137+
var promise = $timeout(function() { throw "Test Error"; }, 0, false);
138+
$timeout.flush();
139+
140+
expect(cancelSpy).not.toHaveBeenCalled();
141+
$timeout.cancel(promise);
142+
expect(cancelSpy).not.toHaveBeenCalled();
143+
}));
109144
});
110145

111146

@@ -147,5 +182,21 @@ describe('$timeout', function() {
147182
it('should not throw a runtime exception when given an undefined promise', inject(function($timeout) {
148183
expect($timeout.cancel()).toBe(false);
149184
}));
185+
186+
187+
it('should forget references to relevant deferred', inject(function($timeout, $browser) {
188+
// $browser.defer.cancel is only called on cancel if the deferred object is still referenced
189+
var cancelSpy = spyOn($browser.defer, 'cancel').andCallThrough();
190+
191+
var promise = $timeout(function() {}, 0, false);
192+
193+
expect(cancelSpy).not.toHaveBeenCalled();
194+
$timeout.cancel(promise);
195+
expect(cancelSpy).toHaveBeenCalledOnce();
196+
197+
// Promise deferred object should already be removed from the list and not cancellable again
198+
$timeout.cancel(promise);
199+
expect(cancelSpy).toHaveBeenCalledOnce();
200+
}));
150201
});
151202
});

travis_build.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,9 @@
22

33
set -xe
44

5-
warn() {
6-
tput setaf 1
7-
echo "[ERROR] Received $1"
8-
tput sgr0
9-
exit 1
10-
}
11-
12-
trap "warn SIGINT" SIGINT
13-
trap "warn SIGTERM" SIGTERM
14-
trap "warn SIGHUP" SIGHUP
15-
165
export SAUCE_ACCESS_KEY=`echo $SAUCE_ACCESS_KEY | rev`
176
./lib/sauce/sauce_connect_setup.sh
187
npm install -g grunt-cli
198
grunt ci-checks package
20-
21-
echo ">>> grunt exited with code: $?"
22-
echo ""
23-
echo ""
24-
259
./lib/sauce/sauce_connect_block.sh
2610
grunt parallel:travis --reporters dots --browsers SL_Chrome

0 commit comments

Comments
 (0)