@@ -64,7 +64,6 @@ var SelectController =
64
64
// ngValue added option values are stored in the selectValueMap, normal interpolations are not
65
65
var realVal = val in self . selectValueMap ? self . selectValueMap [ val ] : val ;
66
66
67
- console . log ( 'read' , 'elval' , val , 'possiblyhashed' , realVal )
68
67
if ( self . hasOption ( realVal ) ) {
69
68
return realVal ;
70
69
}
@@ -76,25 +75,15 @@ var SelectController =
76
75
// Write the value to the select control, the implementation of this changes depending
77
76
// upon whether the select can have multiple values and whether ngOptions is at work.
78
77
self . writeValue = function writeSingleValue ( value ) {
79
- console . log ( 'write' , value , 'hasOption' , self . hasOption ( value ) ) ;
80
78
if ( self . hasOption ( value ) ) {
81
- console . log ( 'hasOption' , value ) ;
82
79
self . removeUnknownOption ( ) ;
83
80
var hashedVal = hashKey ( value ) ;
84
81
if ( hashedVal in self . selectValueMap ) {
85
82
$element . val ( hashedVal ) ;
86
83
} else {
87
84
$element . val ( value ) ;
88
85
}
89
- console . log ( 'after set' , $element . val ( ) )
90
- // console.log('selectValueMap', self.selectValueMap)
91
- // var items = new HashMap();
92
- // items.put(value, value);
93
- // console.log(items, hashKey(value));
94
-
95
- // if (hashKey(value) in self.selectValueMap) {
96
- // console.log('hashed')
97
- // }
86
+
98
87
if ( value === '' ) self . emptyOption . prop ( 'selected' , true ) ; // to make IE9 happy
99
88
} else {
100
89
if ( value == null && self . emptyOption ) {
@@ -166,10 +155,8 @@ var SelectController =
166
155
// The value attribute is set by ngValue
167
156
var oldVal , hashedVal = NaN ;
168
157
optionAttrs . $observe ( 'value' , function valueAttributeObserveAction ( newVal ) {
169
- console . log ( 'ngValue change' , 'n' , newVal , 'o' , oldVal , 'hashed' , hashedVal )
170
158
171
159
var removal ;
172
- console . log ( 'val' , $element . val ( ) ) ;
173
160
var previouslySelected = optionElement . prop ( 'selected' ) ;
174
161
175
162
if ( isDefined ( hashedVal ) ) {
@@ -182,14 +169,11 @@ var SelectController =
182
169
oldVal = newVal ;
183
170
self . selectValueMap [ hashedVal ] = newVal ;
184
171
self . addOption ( newVal , optionElement ) ;
185
- console . log ( 'val' , $element . val ( ) ) ;
186
172
// Set the attribute directly instead of using optionAttrs.$set - this stops the observer
187
173
// from firing a second time. Other $observers on value will also get the result of the
188
174
// ngValue expression, not the hashed value
189
175
optionElement . attr ( 'value' , hashedVal ) ;
190
176
191
- console . log ( 'previouslySelected' , previouslySelected , 'removal' , removal )
192
-
193
177
if ( removal && previouslySelected ) {
194
178
updateModelAfterOptionChange ( ) ;
195
179
}
@@ -198,7 +182,6 @@ var SelectController =
198
182
} else if ( interpolateValueFn ) {
199
183
// The value attribute is interpolated
200
184
optionAttrs . $observe ( 'value' , function valueAttributeObserveAction ( newVal ) {
201
- // console.log('value attribute changed', 'viewVal', self.ngModelCtrl.$viewValue, 'index', optionElement[0].index, 'indices', $element[0].selectedIndex, $element[0].selectedOptions)
202
185
var currentVal = self . readValue ( ) ;
203
186
var removal ;
204
187
var previouslySelected = optionElement . prop ( 'selected' ) ;
@@ -212,9 +195,7 @@ var SelectController =
212
195
oldVal = newVal ;
213
196
self . addOption ( newVal , optionElement ) ;
214
197
215
- console . log ( 'updated interpolated value' , 'new' , newVal , 'removed' , removedVal , 'current' , currentVal ) ;
216
198
if ( removal && previouslySelected ) {
217
- console . log ( 'removed val is currently selected' , $element . val ( ) )
218
199
updateModelAfterOptionChange ( ) ;
219
200
}
220
201
} ) ;
@@ -245,7 +226,6 @@ var SelectController =
245
226
// we only have to handle options becomeing disabled, not enabled
246
227
247
228
if ( newVal === 'true' || newVal && optionElement . prop ( 'selected' ) ) {
248
- console . log ( 'disabled' )
249
229
250
230
if ( self . multiple ) {
251
231
updateModelAfterOptionChange ( true ) ;
@@ -255,39 +235,24 @@ var SelectController =
255
235
}
256
236
oldDisabled = newVal ;
257
237
}
258
-
259
- // else if (isDefined(oldDisabled) && !newVal || newVal === 'false') {
260
- // var val = optionAttrs.value;
261
- // console.log('OA', optionAttrs.value);
262
- // var realVal = val in self.selectValueMap ? self.selectValueMap[val] : val;
263
- // console.log('back from disabled', val, realVal, self.ngModelCtrl.$viewValue);
264
-
265
- // if (realVal === self.ngModelCtrl.$viewValue) {
266
- // self.writeValue(realVal);
267
- // self.ngModelCtrl.$setViewValue(self.readValue());
268
- // }
269
- // }
270
238
} ) ;
271
239
272
240
optionElement . on ( '$destroy' , function ( ) {
273
241
var currentValue = self . readValue ( ) ;
274
242
var removeValue = optionAttrs . value ;
275
243
276
- console . log ( 'destroy' , 'removed' , removeValue , 'elval' , $element . val ( ) )
277
- // console.log('viewValue', self.ngModelCtrl.$viewValue)
278
244
self . removeOption ( removeValue ) ;
279
245
self . ngModelCtrl . $render ( ) ;
280
246
281
247
if ( self . multiple && currentValue && currentValue . indexOf ( removeValue ) !== - 1 ) {
282
248
// When multiple (selected) options are destroyed at the same time, we don't want
283
249
// to run a model update for each of them. Instead, run a single update in the $$postDigest
284
- // NOTE: Will that interfere with the regular model update?
250
+ // NOTE: Will that interfere with the regular model update? No - $setViewValue always triggers a digest
251
+ // However, it might not work if someones removes an option outside of a digest
285
252
updateModelAfterOptionChange ( ) ;
286
253
} else if ( currentValue === removeValue ) {
287
254
self . ngModelCtrl . $setViewValue ( self . readValue ( ) ) ;
288
-
289
255
}
290
- // console.log('read after render', self.readValue())
291
256
} ) ;
292
257
} ;
293
258
} ] ;
@@ -523,7 +488,6 @@ var selectDirective = function() {
523
488
// to the `readValue` method, which can be changed if the select can have multiple
524
489
// selected values or if the options are being generated by `ngOptions`
525
490
element . on ( 'change' , function ( ) {
526
- console . log ( 'on change' , element . val ( ) )
527
491
selectCtrl . removeUnknownOption ( ) ;
528
492
scope . $apply ( function ( ) {
529
493
ngModelCtrl . $setViewValue ( selectCtrl . readValue ( ) ) ;
@@ -540,8 +504,8 @@ var selectDirective = function() {
540
504
// Read value now needs to check each option to see if it is selected
541
505
selectCtrl . readValue = function readMultipleValue ( ) {
542
506
var array = [ ] ;
507
+ var options = element . find ( 'option' )
543
508
forEach ( element . find ( 'option' ) , function ( option ) {
544
- // console.log('read m o', option);
545
509
if ( option . selected && ! option . disabled ) {
546
510
var val = option . value ;
547
511
array . push ( val in selectCtrl . selectValueMap ? selectCtrl . selectValueMap [ val ] : val ) ;
0 commit comments