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

Commit 935226a

Browse files
committed
remove all logging
1 parent 1e0dad1 commit 935226a

File tree

3 files changed

+6
-54
lines changed

3 files changed

+6
-54
lines changed

src/ng/directive/select.js

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ var SelectController =
6464
// ngValue added option values are stored in the selectValueMap, normal interpolations are not
6565
var realVal = val in self.selectValueMap ? self.selectValueMap[val] : val;
6666

67-
console.log('read', 'elval', val, 'possiblyhashed', realVal)
6867
if (self.hasOption(realVal)) {
6968
return realVal;
7069
}
@@ -76,25 +75,15 @@ var SelectController =
7675
// Write the value to the select control, the implementation of this changes depending
7776
// upon whether the select can have multiple values and whether ngOptions is at work.
7877
self.writeValue = function writeSingleValue(value) {
79-
console.log('write', value, 'hasOption', self.hasOption(value));
8078
if (self.hasOption(value)) {
81-
console.log('hasOption', value);
8279
self.removeUnknownOption();
8380
var hashedVal = hashKey(value);
8481
if (hashedVal in self.selectValueMap) {
8582
$element.val(hashedVal);
8683
} else {
8784
$element.val(value);
8885
}
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+
9887
if (value === '') self.emptyOption.prop('selected', true); // to make IE9 happy
9988
} else {
10089
if (value == null && self.emptyOption) {
@@ -166,10 +155,8 @@ var SelectController =
166155
// The value attribute is set by ngValue
167156
var oldVal, hashedVal = NaN;
168157
optionAttrs.$observe('value', function valueAttributeObserveAction(newVal) {
169-
console.log('ngValue change', 'n', newVal, 'o', oldVal, 'hashed', hashedVal)
170158

171159
var removal;
172-
console.log('val', $element.val());
173160
var previouslySelected = optionElement.prop('selected');
174161

175162
if (isDefined(hashedVal)) {
@@ -182,14 +169,11 @@ var SelectController =
182169
oldVal = newVal;
183170
self.selectValueMap[hashedVal] = newVal;
184171
self.addOption(newVal, optionElement);
185-
console.log('val', $element.val());
186172
// Set the attribute directly instead of using optionAttrs.$set - this stops the observer
187173
// from firing a second time. Other $observers on value will also get the result of the
188174
// ngValue expression, not the hashed value
189175
optionElement.attr('value', hashedVal);
190176

191-
console.log('previouslySelected', previouslySelected, 'removal', removal)
192-
193177
if (removal && previouslySelected) {
194178
updateModelAfterOptionChange();
195179
}
@@ -198,7 +182,6 @@ var SelectController =
198182
} else if (interpolateValueFn) {
199183
// The value attribute is interpolated
200184
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)
202185
var currentVal = self.readValue();
203186
var removal;
204187
var previouslySelected = optionElement.prop('selected');
@@ -212,9 +195,7 @@ var SelectController =
212195
oldVal = newVal;
213196
self.addOption(newVal, optionElement);
214197

215-
console.log('updated interpolated value', 'new', newVal, 'removed', removedVal, 'current', currentVal);
216198
if (removal && previouslySelected) {
217-
console.log('removed val is currently selected', $element.val())
218199
updateModelAfterOptionChange();
219200
}
220201
});
@@ -245,7 +226,6 @@ var SelectController =
245226
// we only have to handle options becomeing disabled, not enabled
246227

247228
if (newVal === 'true' || newVal && optionElement.prop('selected')) {
248-
console.log('disabled')
249229

250230
if (self.multiple) {
251231
updateModelAfterOptionChange(true);
@@ -255,39 +235,24 @@ var SelectController =
255235
}
256236
oldDisabled = newVal;
257237
}
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-
// }
270238
});
271239

272240
optionElement.on('$destroy', function() {
273241
var currentValue = self.readValue();
274242
var removeValue = optionAttrs.value;
275243

276-
console.log('destroy', 'removed', removeValue, 'elval', $element.val())
277-
// console.log('viewValue', self.ngModelCtrl.$viewValue)
278244
self.removeOption(removeValue);
279245
self.ngModelCtrl.$render();
280246

281247
if (self.multiple && currentValue && currentValue.indexOf(removeValue) !== -1) {
282248
// When multiple (selected) options are destroyed at the same time, we don't want
283249
// 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
285252
updateModelAfterOptionChange();
286253
} else if (currentValue === removeValue) {
287254
self.ngModelCtrl.$setViewValue(self.readValue());
288-
289255
}
290-
// console.log('read after render', self.readValue())
291256
});
292257
};
293258
}];
@@ -523,7 +488,6 @@ var selectDirective = function() {
523488
// to the `readValue` method, which can be changed if the select can have multiple
524489
// selected values or if the options are being generated by `ngOptions`
525490
element.on('change', function() {
526-
console.log('on change', element.val())
527491
selectCtrl.removeUnknownOption();
528492
scope.$apply(function() {
529493
ngModelCtrl.$setViewValue(selectCtrl.readValue());
@@ -540,8 +504,8 @@ var selectDirective = function() {
540504
// Read value now needs to check each option to see if it is selected
541505
selectCtrl.readValue = function readMultipleValue() {
542506
var array = [];
507+
var options = element.find('option')
543508
forEach(element.find('option'), function(option) {
544-
// console.log('read m o', option);
545509
if (option.selected && !option.disabled) {
546510
var val = option.value;
547511
array.push(val in selectCtrl.selectValueMap ? selectCtrl.selectValueMap[val] : val);

src/ngScenario/browserTrigger.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
evnt = window.document.createEvent('MouseEvents');
8686
x = x || 0;
8787
y = y || 0;
88+
// console.log('trigger', element.relatedTarget, eventType, pressed('ctrl'))
8889
evnt.initMouseEvent(eventType, true, true, window, 0, x, y, x, y, pressed('ctrl'),
8990
pressed('alt'), pressed('shift'), pressed('meta'), 0, relatedTarget);
9091
}
@@ -109,6 +110,7 @@
109110
return originalPreventDefault.apply(evnt, arguments);
110111
};
111112

113+
// console.log('before dispatch', eventType);
112114
element.dispatchEvent(evnt);
113115
finalProcessDefault = !(angular['ff-684208-preventDefault'] || !fakeProcessDefault);
114116

test/ng/directive/selectSpec.js

Lines changed: 0 additions & 14 deletions
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)