Skip to content

Commit 7147591

Browse files
Di PengIgorMinar
Di Peng
authored andcommitted
refactor(widgets): remove input[button, submit, reset, image] and button windgets
These widgets are useless and only trigger extra $updateViews. The only reason we had them was to support ng:change on these widgets, but since there are no bindings present in these cases it doesn't make sense to support ng:change here. It's likely just a leftover from getangular.com Breaking change: ng:change for input[button], input[submit], input[reset], input[image] and button widgets is not supported any more
1 parent ee8e981 commit 7147591

File tree

2 files changed

+1
-26
lines changed

2 files changed

+1
-26
lines changed

src/widgets.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -447,16 +447,11 @@ function noopAccessor() { return { get: noop, set: noop }; }
447447
*
448448
*/
449449
var textWidget = inputWidget('keydown change', modelAccessor, valueAccessor, initWidgetValue(), true),
450-
buttonWidget = inputWidget('click', noopAccessor, noopAccessor, noop),
451450
INPUT_TYPE = {
452451
'text': textWidget,
453452
'textarea': textWidget,
454453
'hidden': textWidget,
455454
'password': textWidget,
456-
'button': buttonWidget,
457-
'submit': buttonWidget,
458-
'reset': buttonWidget,
459-
'image': buttonWidget,
460455
'checkbox': inputWidget('click', modelFormattedAccessor, checkedAccessor, initWidgetValue(false)),
461456
'radio': inputWidget('click', modelFormattedAccessor, radioAccessor, radioInit),
462457
'select-one': inputWidget('change', modelAccessor, valueAccessor, initWidgetValue(null)),
@@ -567,7 +562,7 @@ function inputWidgetSelector(element){
567562

568563
angularWidget('input', inputWidgetSelector);
569564
angularWidget('textarea', inputWidgetSelector);
570-
angularWidget('button', inputWidgetSelector);
565+
571566

572567
/**
573568
* @workInProgress

test/widgetsSpec.js

-20
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,6 @@ describe("widget", function(){
293293
expect(scope.$get('name')).toEqual('Kai');
294294
});
295295

296-
it('should call ng:change on button click', function(){
297-
compile('<input type="button" value="Click Me" ng:change="clicked = true"/>');
298-
browserTrigger(element);
299-
expect(scope.$get('clicked')).toEqual(true);
300-
});
301-
302-
it('should support button alias', function(){
303-
compile('<button ng:change="clicked = true">Click {{"Me"}}.</button>');
304-
browserTrigger(element);
305-
expect(scope.$get('clicked')).toEqual(true);
306-
expect(scope.$element.text()).toEqual("Click Me.");
307-
});
308296

309297
describe('radio', function(){
310298

@@ -417,14 +405,6 @@ describe("widget", function(){
417405
expect(scope.$service('$log').error.logs.shift()[0]).
418406
toMatchError(/Syntax Error: Token '''' is an unexpected token/);
419407
});
420-
421-
it('should report error on ng:change exception', function(){
422-
compile('<button ng:change="a-2=x">click</button>');
423-
browserTrigger(element);
424-
expect(element.hasClass('ng-exception')).toBeTruthy();
425-
expect(scope.$service('$log').error.logs.shift()[0]).
426-
toMatchError(/Syntax Error: Token '=' implies assignment but \[a-2\] can not be assigned to/);
427-
});
428408
});
429409

430410
describe('ng:switch', function(){

0 commit comments

Comments
 (0)