Skip to content

Commit 6b9831d

Browse files
Merge pull request #19 from angular/master
Update upstream
2 parents f9ba158 + 00936ad commit 6b9831d

File tree

9 files changed

+66
-41
lines changed

9 files changed

+66
-41
lines changed

src/ng/directive/input.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ function radioInputType(scope, element, attr, ctrl) {
18201820
}
18211821
};
18221822

1823-
element.on('click', listener);
1823+
element.on('change', listener);
18241824

18251825
ctrl.$render = function() {
18261826
var value = attr.value;
@@ -1854,7 +1854,7 @@ function checkboxInputType(scope, element, attr, ctrl, $sniffer, $browser, $filt
18541854
ctrl.$setViewValue(element[0].checked, ev && ev.type);
18551855
};
18561856

1857-
element.on('click', listener);
1857+
element.on('change', listener);
18581858

18591859
ctrl.$render = function() {
18601860
element[0].checked = ctrl.$viewValue;

src/ng/directive/select.js

+20-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ function setOptionSelectedStatus(optionEl, value) {
4141
* <option value="option-1">Option 1</option>
4242
* <option value="option-2">Option 2</option>
4343
* </select><br>
44-
* <span ng-if="myForm.testSelect.$error.unknownValue">Error: The current model doesn't match any option</span>
44+
* <span class="error" ng-if="myForm.testSelect.$error.unknownValue">
45+
* Error: The current model doesn't match any option</span><br>
4546
*
4647
* <button ng-click="forceUnknownOption()">Force unknown option</button><br>
4748
* </form>
@@ -90,11 +91,11 @@ function setOptionSelectedStatus(optionEl, value) {
9091
* <div ng-controller="ExampleController">
9192
* <form name="myForm">
9293
* <label for="testSelect"> Select: </label><br>
93-
* <select name="testSelect" ng-model="selected" unknown-value-required>
94+
* <select name="testSelect" ng-model="selected" required unknown-value-required>
9495
* <option value="option-1">Option 1</option>
9596
* <option value="option-2">Option 2</option>
9697
* </select><br>
97-
* <span ng-if="myForm.testSelect.$error.required">Error: Please select a value</span><br>
98+
* <span class="error" ng-if="myForm.testSelect.$error.required">Error: Please select a value</span><br>
9899
*
99100
* <button ng-click="forceUnknownOption()">Force unknown option</button><br>
100101
* </form>
@@ -130,6 +131,22 @@ function setOptionSelectedStatus(optionEl, value) {
130131
* };
131132
* });
132133
* </file>
134+
* <file name="protractor.js" type="protractor">
135+
* it('should show the error message when the unknown option is selected', function() {
136+
137+
var error = element(by.className('error'));
138+
139+
expect(error.getText()).toBe('Error: Please select a value');
140+
141+
element(by.cssContainingText('option', 'Option 1')).click();
142+
143+
expect(error.isPresent()).toBe(false);
144+
145+
element(by.tagName('button')).click();
146+
147+
expect(error.getText()).toBe('Error: Please select a value');
148+
});
149+
* </file>
133150
*</example>
134151
*
135152
*

src/ngResource/resource.js

-5
Original file line numberDiff line numberDiff line change
@@ -841,11 +841,6 @@ angular.module('ngResource', ['ng']).
841841
};
842842
});
843843

844-
Resource.bind = function(additionalParamDefaults) {
845-
var extendedParamDefaults = extend({}, paramDefaults, additionalParamDefaults);
846-
return resourceFactory(url, extendedParamDefaults, actions, options);
847-
};
848-
849844
return Resource;
850845
}
851846

test/BinderSpec.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,17 @@ describe('Binder', function() {
401401
expect(optionC.text()).toEqual('C');
402402
}));
403403

404-
it('ItShouldSelectTheCorrectRadioBox', inject(function($rootScope, $compile) {
404+
it('ItShouldSelectTheCorrectRadioBox', inject(function($rootScope, $compile, $rootElement, $document) {
405405
element = $compile(
406406
'<div>' +
407407
'<input type="radio" ng-model="sex" value="female">' +
408408
'<input type="radio" ng-model="sex" value="male">' +
409409
'</div>')($rootScope);
410+
411+
// Append the app to the document so that "click" on a radio/checkbox triggers "change"
412+
// Support: Chrome, Safari 8, 9
413+
jqLite($document[0].body).append($rootElement.append(element));
414+
410415
var female = jqLite(element[0].childNodes[0]);
411416
var male = jqLite(element[0].childNodes[1]);
412417

test/helpers/testabilityPatch.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ function generateInputCompilerHelper(helper) {
319319
};
320320
});
321321
});
322-
inject(function($compile, $rootScope, $sniffer) {
322+
inject(function($compile, $rootScope, $sniffer, $document, $rootElement) {
323323

324324
helper.compileInput = function(inputHtml, mockValidity, scope) {
325325

@@ -341,6 +341,11 @@ function generateInputCompilerHelper(helper) {
341341
// Compile the lot and return the input element
342342
$compile(helper.formElm)(scope);
343343

344+
$rootElement.append(helper.formElm);
345+
// Append the app to the document so that "click" on a radio/checkbox triggers "change"
346+
// Support: Chrome, Safari 8, 9
347+
jqLite($document[0].body).append($rootElement);
348+
344349
spyOn(scope.form, '$addControl').and.callThrough();
345350
spyOn(scope.form, '$$renameControl').and.callThrough();
346351

test/ng/directive/booleanAttrsSpec.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ describe('boolean attr directives', function() {
4242
}));
4343

4444

45-
it('should not bind checked when ngModel is present', inject(function($rootScope, $compile) {
45+
it('should not bind checked when ngModel is present', inject(function($rootScope, $compile, $document, $rootElement) {
4646
// test for https://github.com/angular/angular.js/issues/10662
4747
element = $compile('<input type="checkbox" ng-model="value" ng-false-value="\'false\'" ' +
4848
'ng-true-value="\'true\'" ng-checked="value" />')($rootScope);
49+
50+
// Append the app to the document so that "click" triggers "change"
51+
// Support: Chrome, Safari 8, 9
52+
jqLite($document[0].body).append($rootElement.append(element));
53+
4954
$rootScope.value = 'true';
5055
$rootScope.$digest();
5156
expect(element[0].checked).toBe(true);

test/ng/directive/inputSpec.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -3974,7 +3974,7 @@ describe('input', function() {
39743974

39753975
describe('radio', function() {
39763976

3977-
it('should update the model', function() {
3977+
they('should update the model on $prop event', ['click', 'change'], function(event) {
39783978
var inputElm = helper.compileInput(
39793979
'<input type="radio" ng-model="color" value="white" />' +
39803980
'<input type="radio" ng-model="color" value="red" />' +
@@ -3990,7 +3990,8 @@ describe('input', function() {
39903990
expect(inputElm[1].checked).toBe(true);
39913991
expect(inputElm[2].checked).toBe(false);
39923992

3993-
browserTrigger(inputElm[2], 'click');
3993+
if (event === 'change') inputElm[2].checked = true;
3994+
browserTrigger(inputElm[2], event);
39943995
expect($rootScope.color).toBe('blue');
39953996
});
39963997

@@ -4092,6 +4093,23 @@ describe('input', function() {
40924093
});
40934094

40944095

4096+
they('should update the model on $prop event', ['click', 'change'], function(event) {
4097+
var inputElm = helper.compileInput('<input type="checkbox" ng-model="checkbox" />');
4098+
4099+
expect(inputElm[0].checked).toBe(false);
4100+
4101+
$rootScope.$apply('checkbox = true');
4102+
expect(inputElm[0].checked).toBe(true);
4103+
4104+
$rootScope.$apply('checkbox = false');
4105+
expect(inputElm[0].checked).toBe(false);
4106+
4107+
if (event === 'change') inputElm[0].checked = true;
4108+
browserTrigger(inputElm[0], event);
4109+
expect($rootScope.checkbox).toBe(true);
4110+
});
4111+
4112+
40954113
it('should format booleans', function() {
40964114
var inputElm = helper.compileInput('<input type="checkbox" ng-model="name" />');
40974115

test/ng/directive/ngRepeatSpec.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ describe('ngRepeat', function() {
354354
});
355355

356356

357-
it('should iterate over object with changing primitive property values', function() {
357+
it('should iterate over object with changing primitive property values', inject(function($rootElement, $document) {
358358
// test for issue #933
359359

360360
element = $compile(
@@ -365,6 +365,10 @@ describe('ngRepeat', function() {
365365
'</li>' +
366366
'</ul>')(scope);
367367

368+
// Append the app to the document so that "click" on a radio/checkbox triggers "change"
369+
// Support: Chrome, Safari 8, 9
370+
jqLite($document[0].body).append($rootElement.append(element));
371+
368372
scope.items = {misko: true, shyam: true, zhenbo:true};
369373
scope.$digest();
370374
expect(element.find('li').length).toEqual(3);
@@ -395,7 +399,7 @@ describe('ngRepeat', function() {
395399
expect(element.find('input')[0].checked).toBe(false);
396400
expect(element.find('input')[1].checked).toBe(true);
397401
expect(element.find('input')[2].checked).toBe(true);
398-
});
402+
}));
399403
});
400404

401405
describe('alias as', function() {

test/ngResource/resourceSpec.js

-24
Original file line numberDiff line numberDiff line change
@@ -728,30 +728,6 @@ describe('basic usage', function() {
728728
});
729729

730730

731-
it('should bind default parameters', function() {
732-
$httpBackend.expect('GET', '/CreditCard/123.visa?minimum=0.05').respond({id: 123});
733-
var Visa = CreditCard.bind({verb: '.visa', minimum: 0.05});
734-
var visa = Visa.get({id: 123});
735-
$httpBackend.flush();
736-
expect(visa).toEqualData({id: 123});
737-
});
738-
739-
740-
it('should pass all original arguments when binding default params', function() {
741-
$httpBackend.expect('GET', '/CancellableCreditCard/123.visa').respond({id: 123});
742-
743-
var CancellableCreditCard = $resource('/CancellableCreditCard/:id:verb', {},
744-
{charge: {method: 'POST'}}, {cancellable: true});
745-
var CancellableVisa = CancellableCreditCard.bind({verb: '.visa'});
746-
var visa = CancellableVisa.get({id: 123});
747-
748-
$httpBackend.flush();
749-
750-
expect(visa.$charge).toEqual(jasmine.any(Function));
751-
expect(visa.$cancelRequest).toEqual(jasmine.any(Function));
752-
});
753-
754-
755731
it('should support dynamic default parameters (global)', function() {
756732
var currentGroup = 'students',
757733
Person = $resource('/Person/:group/:id', { group: function() { return currentGroup; }});

0 commit comments

Comments
 (0)