@@ -50,7 +50,7 @@ void main() {
50
50
dirInjector = new DirectiveInjector (null , _.injector, null , null , null , null , null , null );
51
51
});
52
52
53
- describe ('type="text" like ' , () {
53
+ describe ('type="text"' , () {
54
54
it ('should update input value from model' , () {
55
55
_.compile ('<input type="text" ng-model="model">' );
56
56
_.rootScope.apply ();
@@ -87,41 +87,24 @@ void main() {
87
87
expect (_.rootScope.context['model' ]).toEqual ('def' );
88
88
});
89
89
90
- it ('should write to input only if the value is different' ,
91
- (Injector i, Animate animate) {
92
-
93
- NodeAttrs nodeAttrs = new NodeAttrs (new DivElement ());
94
-
95
- var scope = _.rootScope;
96
- var element = new dom.InputElement ();
97
- var ngElement = new NgElement (element, scope, animate);
98
- var ngModelOptions = new NgModelOptions ();
99
-
100
- nodeAttrs['ng-model' ] = 'model' ;
101
- var model = new NgModel (scope, ngElement, dirInjector,
102
- nodeAttrs, new Animate (), null );
90
+ it ('should write to input only if the value is different' , (Injector i, Scope scope) {
91
+ var element = _.compile ('<input type="text" ng-model="model">' );
103
92
dom.querySelector ('body' ).append (element);
104
- var input = new InputTextLike (element, model, scope, ngModelOptions);
105
93
106
- element
107
- ..value = 'abc'
108
- ..selectionStart = 1
109
- ..selectionEnd = 2 ;
94
+ element..value = 'abc'
95
+ ..selectionStart = 1
96
+ ..selectionEnd = 2 ;
110
97
111
- scope.apply (() {
112
- scope.context['model' ] = 'abc' ;
113
- });
98
+ scope.apply ('model = "abc"' );
114
99
115
100
expect (element.value).toEqual ('abc' );
116
101
// No update. selectionStart/End is unchanged.
117
102
expect (element.selectionStart).toEqual (1 );
118
103
expect (element.selectionEnd).toEqual (2 );
119
104
120
- scope.apply (() {
121
- scope.context['model' ] = 'xyz' ;
122
- });
105
+ scope.apply ('model = "xyz"' );
123
106
124
- // Value updated. selectionStart/End changed.
107
+ // Value updated. selectionStart/End changed.
125
108
expect (element.value).toEqual ('xyz' );
126
109
expect (element.selectionStart).toEqual (3 );
127
110
expect (element.selectionEnd).toEqual (3 );
@@ -367,38 +350,21 @@ void main() {
367
350
368
351
});
369
352
370
- it ('should write to input only if value is different' ,
371
- (Injector i, Animate animate) {
372
-
373
- NodeAttrs nodeAttrs = new NodeAttrs (new DivElement ());
374
-
375
- var scope = _.rootScope;
376
- var element = new dom.InputElement ();
377
- var ngElement = new NgElement (element, scope, animate);
378
- var ngModelOptions = new NgModelOptions ();
379
-
380
- nodeAttrs['ng-model' ] = 'model' ;
381
- var model = new NgModel (scope, ngElement, dirInjector,
382
- nodeAttrs, new Animate (), null );
353
+ it ('should write to input only if value is different' , (Injector i, Scope scope) {
354
+ var element = _.compile ('<input type=password ng-model=model>' );
383
355
dom.querySelector ('body' ).append (element);
384
- var input = new InputTextLike (element, model, scope, ngModelOptions);
385
356
386
- element
387
- ..value = 'abc'
388
- ..selectionStart = 1
389
- ..selectionEnd = 2 ;
357
+ element..value = 'abc'
358
+ ..selectionStart = 1
359
+ ..selectionEnd = 2 ;
390
360
391
- scope.apply (() {
392
- scope.context['model' ] = 'abc' ;
393
- });
361
+ scope.apply ('model = "abc"' );
394
362
395
363
expect (element.value).toEqual ('abc' );
396
364
expect (element.selectionStart).toEqual (1 );
397
365
expect (element.selectionEnd).toEqual (2 );
398
366
399
- scope.apply (() {
400
- scope.context['model' ] = 'xyz' ;
401
- });
367
+ scope.apply ('model = "xyz"' );
402
368
403
369
expect (element.value).toEqual ('xyz' );
404
370
expect (element.selectionStart).toEqual (3 );
@@ -459,41 +425,22 @@ void main() {
459
425
expect (_.rootScope.context['model' ]).toEqual ('def' );
460
426
});
461
427
462
- it ('should write to input only if value is different' ,
463
- (Injector i, Animate animate) {
464
-
465
- NodeAttrs nodeAttrs = new NodeAttrs (new DivElement ());
466
-
467
- var scope = _.rootScope;
468
- var element = new dom.InputElement ();
469
- var ngElement = new NgElement (element, scope, animate);
470
- var ngModelOptions = new NgModelOptions ();
471
-
472
- nodeAttrs['ng-model' ] = 'model' ;
473
- var model = new NgModel (scope, ngElement, dirInjector,
474
- nodeAttrs, new Animate (), null );
428
+ it ('should write to input only if value is different' , (Injector i, Scope scope) {
429
+ var element = _.compile ('<input type=search ng-model=model>' );
475
430
dom.querySelector ('body' ).append (element);
476
- var input = new InputTextLike (element, model, scope, ngModelOptions);
477
431
478
- element
479
- ..value = 'abc'
480
- ..selectionStart = 1
481
- ..selectionEnd = 2 ;
432
+ element..value = 'abc'
433
+ ..selectionStart = 1
434
+ ..selectionEnd = 2 ;
482
435
483
- scope.apply (() {
484
- scope.context['model' ] = 'abc' ;
485
- });
436
+ scope.apply ('model = "abc"' );
486
437
487
438
expect (element.value).toEqual ('abc' );
488
- // No update. selectionStart/End is unchanged.
489
439
expect (element.selectionStart).toEqual (1 );
490
440
expect (element.selectionEnd).toEqual (2 );
491
441
492
- scope.apply (() {
493
- scope.context['model' ] = 'xyz' ;
494
- });
442
+ scope.apply ('model = "xyz"' );
495
443
496
- // Value updated. selectionStart/End changed.
497
444
expect (element.value).toEqual ('xyz' );
498
445
expect (element.selectionStart).toEqual (3 );
499
446
expect (element.selectionEnd).toEqual (3 );
@@ -564,38 +511,21 @@ void main() {
564
511
expect (_.rootScope.context['model' ]).toEqual ('def' );
565
512
});
566
513
567
- it ('should write to input only if value is different' ,
568
- (Injector i, Animate animate) {
569
-
570
- NodeAttrs nodeAttrs = new NodeAttrs (new DivElement ());
571
-
572
- var scope = _.rootScope;
573
- var element = new dom.InputElement ();
574
- var ngElement = new NgElement (element, scope, animate);
575
- var ngModelOptions = new NgModelOptions ();
576
-
577
- nodeAttrs['ng-model' ] = 'model' ;
578
- var model = new NgModel (scope, ngElement, dirInjector,
579
- nodeAttrs, new Animate (), null );
514
+ it ('should write to input only if value is different' , (Injector i, Scope scope) {
515
+ var element = _.compile ('<input ng-model=model>' );
580
516
dom.querySelector ('body' ).append (element);
581
- var input = new InputTextLike (element, model, scope, ngModelOptions);
582
517
583
- element
584
- ..value = 'abc'
585
- ..selectionStart = 1
586
- ..selectionEnd = 2 ;
518
+ element..value = 'abc'
519
+ ..selectionStart = 1
520
+ ..selectionEnd = 2 ;
587
521
588
- scope.apply (() {
589
- scope.context['model' ] = 'abc' ;
590
- });
522
+ scope.apply ('model = "abc"' );
591
523
592
524
expect (element.value).toEqual ('abc' );
593
525
expect (element.selectionStart).toEqual (1 );
594
526
expect (element.selectionEnd).toEqual (2 );
595
527
596
- scope.apply (() {
597
- scope.context['model' ] = 'xyz' ;
598
- });
528
+ scope.apply ('model = "xyz"' );
599
529
600
530
expect (element.value).toEqual ('xyz' );
601
531
expect (element.selectionStart).toEqual (3 );
@@ -775,34 +705,21 @@ void main() {
775
705
776
706
// NOTE(deboer): This test passes on Dartium, but fails in the content_shell.
777
707
// The Dart team is looking into this bug.
778
- xit ('should write to input only if value is different' ,
779
- (Injector i, Animate animate) {
780
-
781
- NodeAttrs nodeAttrs = new NodeAttrs (new DivElement ());
782
-
783
- var scope = _.rootScope;
784
- var element = new dom.TextAreaElement ();
785
- var ngElement = new NgElement (element, scope, animate);
786
- var ngModelOptions = new NgModelOptions ();
787
-
788
- nodeAttrs['ng-model' ] = 'model' ;
789
- var model = new NgModel (scope, ngElement, dirInjector,
790
- nodeAttrs, new Animate (), null );
708
+ xit ('should write to input only if value is different' , (Injector i, Scope scope) {
709
+ var element = _.compile ('<textarea ng-model=model></textarea>' );
791
710
dom.querySelector ('body' ).append (element);
792
- var input = new InputTextLike (element, model, scope, ngModelOptions);
793
711
794
- element
795
- ..value = 'abc'
796
- ..selectionStart = 1
797
- ..selectionEnd = 2 ;
712
+ element..value = 'abc'
713
+ ..selectionStart = 1
714
+ ..selectionEnd = 2 ;
798
715
799
- model. render ( ' abc' );
716
+ scope. apply ( 'model = " abc" ' );
800
717
801
718
expect (element.value).toEqual ('abc' );
802
719
expect (element.selectionStart).toEqual (1 );
803
720
expect (element.selectionEnd).toEqual (2 );
804
721
805
- model. render ( ' xyz' );
722
+ scope. apply ( 'model = " xyz" ' );
806
723
807
724
// Setting the value on a textarea doesn't update the selection the way it
808
725
// does on input elements. This stays unchanged.
0 commit comments