Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7078

Show
Ignore:
Timestamp:
06/22/07 14:07:26 (1 year ago)
Author:
mislav
Message:

Prototype: added unit tests for current submit button serialization behavior. Updated TODO.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/branches/form/test/unit/form.html

    r7073 r7078  
    2727  <div>This is not a form element</div> 
    2828  <input type="text" name="val2" id="input_disabled" disabled="disabled" value="5" /> 
    29   <input type="submit" /> 
     29  <input type="submit" name="first_submit" value="Commit it!" /> 
     30  <input type="submit" name="second_submit" value="Delete it!" /> 
    3031  <input type="text" name="action" value="blah" /> 
    3132</form> 
     
    311312      var form = $('form'); 
    312313      [form.getInputs(), Form.getInputs(form)].each(function(inputs){ 
    313         assertEqual(inputs.length, 4); 
     314        assertEqual(inputs.length, 5); 
    314315        assert(inputs instanceof Array); 
    315316        assert(inputs.all(function(input) { return (input.tagName == "INPUT"); })); 
     
    348349      // Checks that disabled element is not included in serialized form. 
    349350      $('input_enabled').enable(); 
    350       assertHashEqual({ val1:4, action:'blah' }, $('form').serialize(true)); 
     351      assertHashEqual({ 
     352                        val1:4, action:'blah', 
     353                        first_submit:'Commit it!', second_submit:'Delete it!' 
     354                      }, 
     355                      $('form').serialize(true)); 
    351356 
    352357      // should not eat empty values for duplicate names  
     
    392397      request = $("form").request(); 
    393398      assert($("form").hasAttribute("method")); 
    394       assert(request.url.endsWith("fixtures/empty.js?val1=4&action=blah")); 
     399      assert(request.url.include("fixtures/empty.js?val1=4")); 
    395400      assertEqual("get", request.method); 
    396401       
    397402      request = $("form").request({ method: "put", parameters: {val2: "hello"} }); 
    398403      assert(request.url.endsWith("fixtures/empty.js")); 
    399       assertHashEqual({ val1:4, action:'blah', val2:'hello' }, request.options.parameters); 
     404      assertEqual(4, request.options.parameters['val1']); 
     405      assertEqual('hello', request.options.parameters['val2']); 
    400406      assertEqual("post", request.method); 
    401407      assertEqual("put", request.parameters['_method']); 
  • spinoffs/prototype/branches/form/TODO

    r6609 r7078  
    11* [done] Form.Element.setValue (r6526:6530 fixes #5902) 
    2 * findFirstElement takes tabindexes into account: #7595 
    3 * is #3065 (findFirstElement) something the framework should care about? 
    4 * #6301 (filter for serialize) is not a bad idea (use cases come to mind)! 
     2* [done] findFirstElement takes tabindexes into account (r6628 fixes #7595) 
     3* [wontfix] is #3065 (findFirstElement) something the framework should care about? 
    54* Ability to intercept serialization for individual elements 
    6 * fix #5031: Form.serialize with multiple submit buttons 
    7   related: review #8211 
     5* fix #5031: Form.serialize with multiple submit buttons (related: #8211) 
    86* research if #6326 (selectedIndex changes on hover) can be fixed 
    97* #7909 (application/xhtml+xml) is a blocker (is this a DOM extensions issue??) 
     
    1513Selection notes: 
    1614 
     15  * http://developer.mozilla.org/en/docs/DOM:window.getSelection 
     16  * http://developer.mozilla.org/en/docs/DOM:Selection 
     17 
    1718if (!document.getSelection) { 
    1819  if (document.selection) 
     
    2223} 
    2324 
    24 * http://developer.mozilla.org/en/docs/DOM:window.getSelection 
    25 * http://developer.mozilla.org/en/docs/DOM:Selection 
     25// from Proto unit tests: Firefox, IE, and Safari 2+ 
     26function getSelection(element){ 
     27  try { 
     28    if (typeof element.selectionStart == 'number') { 
     29      return element.value.substring(element.selectionStart, element.selectionEnd); 
     30    } else if (document.selection && document.selection.createRange) { 
     31      return document.selection.createRange().text; 
     32    } 
     33  } 
     34  catch(e){ return null } 
     35