Skip to content

Commit

Permalink
Merge pull request #145 from angular/master
Browse files Browse the repository at this point in the history
Update upstream
  • Loading branch information
GulajavaMinistudio authored Jun 1, 2018
2 parents a7e73ab + 459997b commit 0b5f6e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/ng/directive/ngModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ function NgModelController($scope, $exceptionHandler, $attr, $element, $parse, $
this.$$currentValidationRunId = 0;

this.$$scope = $scope;
this.$$rootScope = $scope.$root;
this.$$attr = $attr;
this.$$element = $element;
this.$$animate = $animate;
Expand Down Expand Up @@ -864,7 +865,7 @@ NgModelController.prototype = {
this.$$pendingDebounce = this.$$timeout(function() {
that.$commitViewValue();
}, debounceDelay);
} else if (this.$$scope.$root.$$phase) {
} else if (this.$$rootScope.$$phase) {
this.$commitViewValue();
} else {
this.$$scope.$apply(function() {
Expand Down
10 changes: 8 additions & 2 deletions test/ng/directive/ngModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('ngModel', function() {

describe('NgModelController', function() {
/* global NgModelController: false */
var ctrl, scope, ngModelAccessor, element, parentFormCtrl;
var ctrl, scope, element, parentFormCtrl;

beforeEach(inject(function($rootScope, $controller) {
var attrs = {name: 'testAlias', ngModel: 'value'};
Expand All @@ -21,7 +21,6 @@ describe('ngModel', function() {
element = jqLite('<form><input></form>');

scope = $rootScope;
ngModelAccessor = jasmine.createSpy('ngModel accessor');
ctrl = $controller(NgModelController, {
$scope: scope,
$element: element.find('input'),
Expand Down Expand Up @@ -438,6 +437,13 @@ describe('ngModel', function() {
expect(ctrl.$modelValue).toBe('c');
expect(scope.value).toBe('c');
}));


it('should not throw an error if the scope has been destroyed', function() {
scope.$destroy();
ctrl.$setViewValue('some-val');
expect(ctrl.$viewValue).toBe('some-val');
});
});


Expand Down

0 comments on commit 0b5f6e3

Please sign in to comment.