Changeset 6530
- Timestamp:
- 04/16/07 11:27:47 (1 year ago)
- Files:
-
- spinoffs/prototype/branches/form/src/form.js (modified) (1 diff)
- spinoffs/prototype/branches/form/test/unit/form.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinoffs/prototype/branches/form/src/form.js
r6529 r6530 187 187 var Field = Form.Element; 188 188 var $F = function(element, value) { 189 return Form.Element[value === undefined ? 'getValue' : 'setValue'](element, value); 189 return value === undefined ? Form.Element.getValue(element) : 190 (Form.Element.setValue(element, value), value); 190 191 } 191 192 spinoffs/prototype/branches/form/test/unit/form.html
r6529 r6530 391 391 var input = $('input_enabled'); 392 392 input.setValue('foo'); 393 assertEqual('foo', input.getValue()); 394 input.setValue(input.getAttribute('value')); 393 assertEqual('foo', input.getValue(), 'value improperly set'); 394 395 // shortcut method always returns value 396 assertEqual('bar', $F('input_enabled', 'bar'), 397 '$F should return value even if setter'); 398 assertEqual('bar', $F('input_enabled'), 'value improperly set by $F'); 399 // ... but setValue allows for chaining 400 assertEqual(input, input.setValue(input.getAttribute('value')), 401 'setValue chaining is broken'); 402 395 403 // checkbox 396 404 input = $('checkbox_hack'); 397 405 input.setValue(false); 398 assertEqual(null, input.getValue() );406 assertEqual(null, input.getValue(), 'checkbox should be unchecked'); 399 407 input.setValue(true); 400 assertEqual("1", input.getValue() );408 assertEqual("1", input.getValue(), 'checkbox should be checked'); 401 409 // selectbox 402 410 input = $('form_selects')['vu']; 403 411 input.setValue('3'); 404 assertEqual('3', input.getValue() );412 assertEqual('3', input.getValue(), 'single select option improperly set'); 405 413 input.setValue('1'); 406 414 assertEqual('1', input.getValue()); … … 408 416 input = $('form_selects')['vm[]']; 409 417 input.setValue(['2', '3']); 410 assertEnumEqual(['2', '3'], input.getValue()); 418 assertEnumEqual(['2', '3'], input.getValue(), 419 'multiple select options improperly set'); 411 420 // should this work? 412 421 // input.setValue('1');