Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 61e9d47

Browse files
committed
remove all logging
1 parent aab8001 commit 61e9d47

File tree

3 files changed

+5
-54
lines changed

3 files changed

+5
-54
lines changed

src/ng/directive/select.js

+4-40
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ var SelectController =
5555
// ngValue added option values are stored in the selectValueMap, normal interpolations are not
5656
var realVal = val in self.selectValueMap ? self.selectValueMap[val] : val;
5757

58-
console.log('read', 'elval', val, 'possiblyhashed', realVal)
5958
if (self.hasOption(realVal)) {
6059
return realVal;
6160
}
@@ -67,25 +66,15 @@ var SelectController =
6766
// Write the value to the select control, the implementation of this changes depending
6867
// upon whether the select can have multiple values and whether ngOptions is at work.
6968
self.writeValue = function writeSingleValue(value) {
70-
console.log('write', value, 'hasOption', self.hasOption(value));
7169
if (self.hasOption(value)) {
72-
console.log('hasOption', value);
7370
self.removeUnknownOption();
7471
var hashedVal = hashKey(value);
7572
if (hashedVal in self.selectValueMap) {
7673
$element.val(hashedVal);
7774
} else {
7875
$element.val(value);
7976
}
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+
8978
if (value === '') self.emptyOption.prop('selected', true); // to make IE9 happy
9079
} else {
9180
if (value == null && self.emptyOption) {
@@ -156,10 +145,8 @@ var SelectController =
156145
// The value attribute is set by ngValue
157146
var oldVal, hashedVal = NaN;
158147
optionAttrs.$observe('value', function valueAttributeObserveAction(newVal) {
159-
console.log('ngValue change', 'n', newVal, 'o', oldVal, 'hashed', hashedVal)
160148

161149
var removal;
162-
console.log('val', $element.val());
163150
var previouslySelected = optionElement.prop('selected');
164151

165152
if (isDefined(hashedVal)) {
@@ -172,14 +159,11 @@ var SelectController =
172159
oldVal = newVal;
173160
self.selectValueMap[hashedVal] = newVal;
174161
self.addOption(newVal, optionElement);
175-
console.log('val', $element.val());
176162
// Set the attribute directly instead of using optionAttrs.$set - this stops the observer
177163
// from firing a second time. Other $observers on value will also get the result of the
178164
// ngValue expression, not the hashed value
179165
optionElement.attr('value', hashedVal);
180166

181-
console.log('previouslySelected', previouslySelected, 'removal', removal)
182-
183167
if (removal && previouslySelected) {
184168
updateModelAfterOptionChange();
185169
}
@@ -188,7 +172,6 @@ var SelectController =
188172
} else if (interpolateValueFn) {
189173
// The value attribute is interpolated
190174
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)
192175
var currentVal = self.readValue();
193176
var removal;
194177
var previouslySelected = optionElement.prop('selected');
@@ -202,9 +185,7 @@ var SelectController =
202185
oldVal = newVal;
203186
self.addOption(newVal, optionElement);
204187

205-
console.log('updated interpolated value', 'new', newVal, 'removed', removedVal, 'current', currentVal);
206188
if (removal && previouslySelected) {
207-
console.log('removed val is currently selected', $element.val())
208189
updateModelAfterOptionChange();
209190
}
210191
});
@@ -235,7 +216,6 @@ var SelectController =
235216
// we only have to handle options becomeing disabled, not enabled
236217

237218
if (newVal === 'true' || newVal && optionElement.prop('selected')) {
238-
console.log('disabled')
239219

240220
if (self.multiple) {
241221
updateModelAfterOptionChange(true);
@@ -245,39 +225,24 @@ var SelectController =
245225
}
246226
oldDisabled = newVal;
247227
}
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-
// }
260228
});
261229

262230
optionElement.on('$destroy', function() {
263231
var currentValue = self.readValue();
264232
var removeValue = optionAttrs.value;
265233

266-
console.log('destroy', 'removed', removeValue, 'elval', $element.val())
267-
// console.log('viewValue', self.ngModelCtrl.$viewValue)
268234
self.removeOption(removeValue);
269235
self.ngModelCtrl.$render();
270236

271237
if (self.multiple && currentValue && currentValue.indexOf(removeValue) !== -1) {
272238
// When multiple (selected) options are destroyed at the same time, we don't want
273239
// 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
275242
updateModelAfterOptionChange();
276243
} else if (currentValue === removeValue) {
277244
self.ngModelCtrl.$setViewValue(self.readValue());
278-
279245
}
280-
// console.log('read after render', self.readValue())
281246
});
282247
};
283248
}];
@@ -513,7 +478,6 @@ var selectDirective = function() {
513478
// to the `readValue` method, which can be changed if the select can have multiple
514479
// selected values or if the options are being generated by `ngOptions`
515480
element.on('change', function() {
516-
console.log('on change', element.val())
517481
selectCtrl.removeUnknownOption();
518482
scope.$apply(function() {
519483
ngModelCtrl.$setViewValue(selectCtrl.readValue());
@@ -530,8 +494,8 @@ var selectDirective = function() {
530494
// Read value now needs to check each option to see if it is selected
531495
selectCtrl.readValue = function readMultipleValue() {
532496
var array = [];
497+
var options = element.find('option')
533498
forEach(element.find('option'), function(option) {
534-
// console.log('read m o', option);
535499
if (option.selected && !option.disabled) {
536500
var val = option.value;
537501
array.push(val in selectCtrl.selectValueMap ? selectCtrl.selectValueMap[val] : val);

src/ngMock/browserTrigger.js

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
evnt = window.document.createEvent('MouseEvents');
9696
x = x || 0;
9797
y = y || 0;
98+
// console.log('trigger', element.relatedTarget, eventType, pressed('ctrl'))
9899
evnt.initMouseEvent(eventType, true, true, window, 0, x, y, x, y, pressed('ctrl'),
99100
pressed('alt'), pressed('shift'), pressed('meta'), 0, relatedTarget);
100101
}

test/ng/directive/selectSpec.js

-14
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,6 @@ describe('select', function() {
13271327
expect(selectController.removeOption.calls.argsFor(0)[0]).toBe(prop);
13281328
}
13291329

1330-
console.log(element);
13311330

13321331
expect(scope.selected).toBe(null);
13331332
expect(element[0].selectedIndex).toBe(0);
@@ -1483,15 +1482,13 @@ describe('select', function() {
14831482
expect(optionElements.length).toEqual(3);
14841483
expect(scope.obj.value).toBe(prop === 'ngValue' ? A : 'A');
14851484

1486-
console.log('---------------')
14871485
scope.options.shift();
14881486
scope.$digest();
14891487

14901488
optionElements = element.find('option');
14911489
expect(optionElements.length).toEqual(3);
14921490
expect(scope.obj.value).toBe(null);
14931491
expect(element.val()).toBe(prop === 'ngValue' ? '? object:4 ?' : '? string:A ?')
1494-
console.log('------');
14951492
});
14961493

14971494

@@ -1645,7 +1642,6 @@ describe('select', function() {
16451642
expect(optionElements.length).toEqual(3);
16461643
expect(scope.obj.value).toBe('A');
16471644
expect(element.val()).toBe(prop === 'ngValue' ? 'string:A' : 'A');
1648-
console.log('------------------end------------------')
16491645
});
16501646

16511647

@@ -1704,7 +1700,6 @@ describe('select', function() {
17041700
expect(optionElements.length).toEqual(4);
17051701
expect(scope.obj.value).toBe(null);
17061702
expect(element.val()).toBe('? object:null ?');
1707-
console.log('------------------end------------------')
17081703
});
17091704

17101705

@@ -1753,7 +1748,6 @@ describe('select', function() {
17531748
expect(optionElements.length).toEqual(3);
17541749
expect(optionElements[2].selected).toBe(true);
17551750
expect(scope.obj.value).toEqual(prop === 'ngValue' ? {name: 'C', $$hashKey: 'object:4'} : 'C');
1756-
console.log('---------------end------------------')
17571751
});
17581752

17591753

@@ -1803,7 +1797,6 @@ describe('select', function() {
18031797
expect(optionElements[2].selected).toBe(true);
18041798
expect(scope.obj.value).toBe('C');
18051799

1806-
console.log('----------------')
18071800
scope.options = [
18081801
{name: 'A'},
18091802
{name: 'B'},
@@ -1816,7 +1809,6 @@ describe('select', function() {
18161809
expect(optionElements.length).toEqual(3);
18171810
expect(optionElements[2].selected).toBe(true);
18181811
expect(scope.obj.value).toBe('C');
1819-
console.log('---------------end------------------')
18201812
});
18211813

18221814
describe('when multiple', function() {
@@ -1867,7 +1859,6 @@ describe('select', function() {
18671859
expect(optionElements.length).toEqual(3);
18681860
expect(scope.obj.value).toEqual(prop === 'ngValue' ? [A, C] : ['A', 'C']);
18691861

1870-
console.log('-----------before shift------------')
18711862

18721863
ngModelCtrlSpy.calls.reset();
18731864
scope.options.shift();
@@ -1879,7 +1870,6 @@ describe('select', function() {
18791870
expect(scope.obj.value).toEqual([]);
18801871
expect(element.val()).toBe(null);
18811872
expect(ngModelCtrlSpy).toHaveBeenCalledTimes(1);
1882-
console.log('------');
18831873
});
18841874

18851875
they('should set the model to null when the currently selected option with $prop changes its value',
@@ -1939,7 +1929,6 @@ describe('select', function() {
19391929
expect(element.val()).toBe(null);
19401930
expect(ngModelCtrlSpy).toHaveBeenCalledTimes(1);
19411931

1942-
console.log('----------------end---------------');
19431932
});
19441933

19451934
they('should set the model to null when the currently selected option with $prop is disabled',
@@ -2049,7 +2038,6 @@ describe('select', function() {
20492038
expect(optionElements[1].selected).toBe(true);
20502039
expect(optionElements[2].selected).toBe(true);
20512040
expect(scope.obj.value).toEqual(prop === 'ngValue' ? [{ name: 'B', $$hashKey: 'object:4'}, {name: 'C', $$hashKey: 'object:5'}] : ['B', 'C']);
2052-
console.log('---------------end------------------')
20532041
});
20542042

20552043
they('should keep selection and model when a repeated options with track by are replaced with equal options',
@@ -2099,7 +2087,6 @@ describe('select', function() {
20992087
expect(optionElements[2].selected).toBe(true);
21002088
expect(scope.obj.value).toEqual(['B', 'C']);
21012089

2102-
console.log('----------------')
21032090
scope.options = [
21042091
{name: 'A'},
21052092
{name: 'B'},
@@ -2113,7 +2100,6 @@ describe('select', function() {
21132100
expect(optionElements[1].selected).toBe(true);
21142101
expect(optionElements[2].selected).toBe(true);
21152102
expect(scope.obj.value).toEqual(['B', 'C']);
2116-
console.log('---------------end------------------')
21172103
});
21182104

21192105
});

0 commit comments

Comments
 (0)