Skip to content

Update upstream #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1557,19 +1557,15 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}
// We must run this hook in an apply since the $$postDigest runs outside apply
$rootScope.$apply(function() {
var errors = [];
for (var i = 0, ii = onChangesQueue.length; i < ii; ++i) {
try {
onChangesQueue[i]();
} catch (e) {
errors.push(e);
$exceptionHandler(e);
}
}
// Reset the queue to trigger a new schedule next time there is a change
onChangesQueue = undefined;
if (errors.length) {
throw errors;
}
});
} finally {
onChangesTtl++;
Expand Down
12 changes: 5 additions & 7 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5075,16 +5075,15 @@ describe('$compile', function() {
$rootScope.$apply('a = 42');

// The first component's error should be logged
var errors = $exceptionHandler.errors.pop();
expect(errors[0]).toEqual(new Error('bad hook'));
expect($exceptionHandler.errors.pop()).toEqual(new Error('bad hook'));

// The second component's changes should still be called
expect($log.info.logs.pop()).toEqual(['onChange']);
});
});


it('should collect up all `$onChanges` errors into one throw', function() {
it('should throw `$onChanges` errors immediately', function() {
function ThrowingController() {
this.$onChanges = function(change) {
throw new Error('bad hook: ' + this.prop);
Expand Down Expand Up @@ -5113,10 +5112,9 @@ describe('$compile', function() {

$rootScope.$apply('a = 42');

// Both component's error should be logged
var errors = $exceptionHandler.errors.pop();
expect(errors.pop()).toEqual(new Error('bad hook: 84'));
expect(errors.pop()).toEqual(new Error('bad hook: 42'));
// Both component's error should be logged individually
expect($exceptionHandler.errors.pop()).toEqual(new Error('bad hook: 84'));
expect($exceptionHandler.errors.pop()).toEqual(new Error('bad hook: 42'));
});
});
});
Expand Down