@@ -55,7 +55,6 @@ var SelectController =
55
55
// ngValue added option values are stored in the selectValueMap, normal interpolations are not
56
56
var realVal = val in self . selectValueMap ? self . selectValueMap [ val ] : val ;
57
57
58
- console . log ( 'read' , 'elval' , val , 'possiblyhashed' , realVal )
59
58
if ( self . hasOption ( realVal ) ) {
60
59
return realVal ;
61
60
}
@@ -67,25 +66,15 @@ var SelectController =
67
66
// Write the value to the select control, the implementation of this changes depending
68
67
// upon whether the select can have multiple values and whether ngOptions is at work.
69
68
self . writeValue = function writeSingleValue ( value ) {
70
- console . log ( 'write' , value , 'hasOption' , self . hasOption ( value ) ) ;
71
69
if ( self . hasOption ( value ) ) {
72
- console . log ( 'hasOption' , value ) ;
73
70
self . removeUnknownOption ( ) ;
74
71
var hashedVal = hashKey ( value ) ;
75
72
if ( hashedVal in self . selectValueMap ) {
76
73
$element . val ( hashedVal ) ;
77
74
} else {
78
75
$element . val ( value ) ;
79
76
}
80
- console . log ( 'after set' , $element . val ( ) )
81
- // console.log('selectValueMap', self.selectValueMap)
82
- // var items = new HashMap();
83
- // items.put(value, value);
84
- // console.log(items, hashKey(value));
85
-
86
- // if (hashKey(value) in self.selectValueMap) {
87
- // console.log('hashed')
88
- // }
77
+
89
78
if ( value === '' ) self . emptyOption . prop ( 'selected' , true ) ; // to make IE9 happy
90
79
} else {
91
80
if ( value == null && self . emptyOption ) {
@@ -156,10 +145,8 @@ var SelectController =
156
145
// The value attribute is set by ngValue
157
146
var oldVal , hashedVal = NaN ;
158
147
optionAttrs . $observe ( 'value' , function valueAttributeObserveAction ( newVal ) {
159
- console . log ( 'ngValue change' , 'n' , newVal , 'o' , oldVal , 'hashed' , hashedVal )
160
148
161
149
var removal ;
162
- console . log ( 'val' , $element . val ( ) ) ;
163
150
var previouslySelected = optionElement . prop ( 'selected' ) ;
164
151
165
152
if ( isDefined ( hashedVal ) ) {
@@ -172,14 +159,11 @@ var SelectController =
172
159
oldVal = newVal ;
173
160
self . selectValueMap [ hashedVal ] = newVal ;
174
161
self . addOption ( newVal , optionElement ) ;
175
- console . log ( 'val' , $element . val ( ) ) ;
176
162
// Set the attribute directly instead of using optionAttrs.$set - this stops the observer
177
163
// from firing a second time. Other $observers on value will also get the result of the
178
164
// ngValue expression, not the hashed value
179
165
optionElement . attr ( 'value' , hashedVal ) ;
180
166
181
- console . log ( 'previouslySelected' , previouslySelected , 'removal' , removal )
182
-
183
167
if ( removal && previouslySelected ) {
184
168
updateModelAfterOptionChange ( ) ;
185
169
}
@@ -188,7 +172,6 @@ var SelectController =
188
172
} else if ( interpolateValueFn ) {
189
173
// The value attribute is interpolated
190
174
optionAttrs . $observe ( 'value' , function valueAttributeObserveAction ( newVal ) {
191
- // console.log('value attribute changed', 'viewVal', self.ngModelCtrl.$viewValue, 'index', optionElement[0].index, 'indices', $element[0].selectedIndex, $element[0].selectedOptions)
192
175
var currentVal = self . readValue ( ) ;
193
176
var removal ;
194
177
var previouslySelected = optionElement . prop ( 'selected' ) ;
@@ -202,9 +185,7 @@ var SelectController =
202
185
oldVal = newVal ;
203
186
self . addOption ( newVal , optionElement ) ;
204
187
205
- console . log ( 'updated interpolated value' , 'new' , newVal , 'removed' , removedVal , 'current' , currentVal ) ;
206
188
if ( removal && previouslySelected ) {
207
- console . log ( 'removed val is currently selected' , $element . val ( ) )
208
189
updateModelAfterOptionChange ( ) ;
209
190
}
210
191
} ) ;
@@ -235,7 +216,6 @@ var SelectController =
235
216
// we only have to handle options becomeing disabled, not enabled
236
217
237
218
if ( newVal === 'true' || newVal && optionElement . prop ( 'selected' ) ) {
238
- console . log ( 'disabled' )
239
219
240
220
if ( self . multiple ) {
241
221
updateModelAfterOptionChange ( true ) ;
@@ -245,39 +225,24 @@ var SelectController =
245
225
}
246
226
oldDisabled = newVal ;
247
227
}
248
-
249
- // else if (isDefined(oldDisabled) && !newVal || newVal === 'false') {
250
- // var val = optionAttrs.value;
251
- // console.log('OA', optionAttrs.value);
252
- // var realVal = val in self.selectValueMap ? self.selectValueMap[val] : val;
253
- // console.log('back from disabled', val, realVal, self.ngModelCtrl.$viewValue);
254
-
255
- // if (realVal === self.ngModelCtrl.$viewValue) {
256
- // self.writeValue(realVal);
257
- // self.ngModelCtrl.$setViewValue(self.readValue());
258
- // }
259
- // }
260
228
} ) ;
261
229
262
230
optionElement . on ( '$destroy' , function ( ) {
263
231
var currentValue = self . readValue ( ) ;
264
232
var removeValue = optionAttrs . value ;
265
233
266
- console . log ( 'destroy' , 'removed' , removeValue , 'elval' , $element . val ( ) )
267
- // console.log('viewValue', self.ngModelCtrl.$viewValue)
268
234
self . removeOption ( removeValue ) ;
269
235
self . ngModelCtrl . $render ( ) ;
270
236
271
237
if ( self . multiple && currentValue && currentValue . indexOf ( removeValue ) !== - 1 ) {
272
238
// When multiple (selected) options are destroyed at the same time, we don't want
273
239
// to run a model update for each of them. Instead, run a single update in the $$postDigest
274
- // NOTE: Will that interfere with the regular model update?
240
+ // NOTE: Will that interfere with the regular model update? No - $setViewValue always triggers a digest
241
+ // However, it might not work if someones removes an option outside of a digest
275
242
updateModelAfterOptionChange ( ) ;
276
243
} else if ( currentValue === removeValue ) {
277
244
self . ngModelCtrl . $setViewValue ( self . readValue ( ) ) ;
278
-
279
245
}
280
- // console.log('read after render', self.readValue())
281
246
} ) ;
282
247
} ;
283
248
} ] ;
@@ -513,7 +478,6 @@ var selectDirective = function() {
513
478
// to the `readValue` method, which can be changed if the select can have multiple
514
479
// selected values or if the options are being generated by `ngOptions`
515
480
element . on ( 'change' , function ( ) {
516
- console . log ( 'on change' , element . val ( ) )
517
481
selectCtrl . removeUnknownOption ( ) ;
518
482
scope . $apply ( function ( ) {
519
483
ngModelCtrl . $setViewValue ( selectCtrl . readValue ( ) ) ;
@@ -530,8 +494,8 @@ var selectDirective = function() {
530
494
// Read value now needs to check each option to see if it is selected
531
495
selectCtrl . readValue = function readMultipleValue ( ) {
532
496
var array = [ ] ;
497
+ var options = element . find ( 'option' )
533
498
forEach ( element . find ( 'option' ) , function ( option ) {
534
- // console.log('read m o', option);
535
499
if ( option . selected && ! option . disabled ) {
536
500
var val = option . value ;
537
501
array . push ( val in selectCtrl . selectValueMap ? selectCtrl . selectValueMap [ val ] : val ) ;
0 commit comments