Ticket #2844: dojo.io.FormBind_0.4.X_20070723.patch

File dojo.io.FormBind_0.4.X_20070723.patch, 6.3 kB (added by jaredj, 18 months ago)
  • src/io/ScriptSrcIO.js

     
    119119                var query = ""; 
    120120                 
    121121                if(kwArgs["formNode"]){ 
    122                         var ta = kwArgs.formNode.getAttribute("action"); 
     122                        var ta = dojo.io._getAttribute(kwArgs.formNode, "action"); 
    123123                        if((ta)&&(!kwArgs["url"])){ url = ta; } 
    124                         var tp = kwArgs.formNode.getAttribute("method"); 
     124                        var tp = dojo.io._getAttribute(kwArgs.formNode, "method"); 
    125125                        if((tp)&&(!kwArgs["method"])){ kwArgs.method = tp; } 
    126126                        query += dojo.io.encodeForm(kwArgs.formNode, kwArgs.encoding, kwArgs["formFilter"]); 
    127127                } 
  • src/io/BrowserIO.js

     
    4848        dojo.io.bind(args); 
    4949} 
    5050 
     51dojo.io._getAttribute = function(node, key){ 
     52        //      summary:         
     53        //              Function to get around IE problems with getAttribute. 
     54        //              See tracker: 2844        
     55        var attrNode = node.getAttributeNode(key); 
     56        if(attrNode){ 
     57                return attrNode.value; 
     58        } 
     59        return null; 
     60} 
     61 
     62 
    5163dojo.io.formFilter = function(/*DOMNode*/node) { 
    5264        //summary: Returns true if the node is an input element that is enabled, has 
    5365        //a name, and whose type is one of the following values: ["file", "submit", "image", "reset", "button"] 
     
    476488                var url = kwArgs.url; 
    477489                var query = ""; 
    478490                if(kwArgs["formNode"]){ 
    479                         var ta = kwArgs.formNode.getAttribute("action"); 
     491                        var ta = dojo.io._getAttribute(kwArgs.formNode, "action"); 
    480492                        if((ta)&&(!kwArgs["url"])){ url = ta; } 
    481                         var tp = kwArgs.formNode.getAttribute("method"); 
     493                        var tp = dojo.io._getAttribute(kwArgs.formNode, "method"); 
    482494                        if((tp)&&(!kwArgs["method"])){ kwArgs.method = tp; } 
    483495                        query += dojo.io.encodeForm(kwArgs.formNode, kwArgs.encoding, kwArgs["formFilter"]); 
    484496                } 
  • src/io/IframeIO.js

     
    107107                                        } 
    108108                                } 
    109109                                if(cr["url"]){ 
    110                                         cr._originalAction = fn.getAttribute("action"); 
     110                                        cr._originalAction = dojo.io._getAttribute(fn, "action"); 
    111111                                        fn.setAttribute("action", cr.url); 
    112112                                } 
    113                                 if(!fn.getAttribute("method")){ 
     113                                if(!dojo.io._getAttribute(fn, "method")){ 
    114114                                        fn.setAttribute("method", (cr["method"]) ? cr["method"] : "post"); 
    115115                                } 
    116116                                cr._originalTarget = fn.getAttribute("target"); 
  • tests/io/test_FormBind.html

     
     1<html> 
     2        <head> 
     3                <title>Test of dojo.io.FormBind</title> 
     4        </head> 
     5        <body> 
     6                NB: This page uses some "document.write" statements to print JS variables, please allow the blocked content for it to operate properly! 
     7 
     8                <br> 
     9                <br> 
     10 
     11                <b> 
     12                        The two forms below both use dojo.io.FormBind to submit through Dojo. 
     13                        <br> 
     14                        The response handler simply uses alert() to signal that the rsponse was received. 
     15                        <br> 
     16                        The purpose of this test is to verify that form submission behavior is consistent between IE and Firefox. 
     17                        Notably, that the problem reported in tracker #2844 is fixed. 
     18                </b> 
     19 
     20                <br> 
     21                <br> 
     22 
     23                Here is a good form: 
     24                <form name="testform_good" id="testform_good_id" action="test_FormBind.html" method="POST"> 
     25                        <input type="submit" name="input1" value="input1"/> 
     26                        <br> 
     27                        <input type="submit" name="not_action" value="not_action"/> 
     28                </form> 
     29 
     30                Here is a bad (from IE's handling of attributes such as action and method) form: 
     31                <form name="testform_bad" id="testform_ie_bad_id" action="test_FormBind.html" method="POST"> 
     32                        <input type="submit" name="input1" value="input1"/> 
     33                        <br> 
     34                        <input type="submit" name="action" value="action"/> 
     35                </form> 
     36 
     37                <br> 
     38                <br> 
     39 
     40                <b> 
     41                        Below you can see the various ways to try to get the form's action and their results for each form. 
     42                        <br> 
     43                        Load this page on FF and on IE and verify the form submission works properly. 
     44                </b> 
     45 
     46                <script src="../../dojo.js" type="text/javascript"></script> 
     47                <script type="text/javascript"> 
     48                        dojo.require("dojo.io.BrowserIO"); 
     49                        var tfgood = document.getElementById( "testform_good_id" ); 
     50                        var tfiebad = document.getElementById( "testform_ie_bad_id" ); 
     51 
     52                        var handler = function(){ 
     53                                alert( "response received" ); 
     54                        }; 
     55 
     56                        // Bind the form submission (by button click) to the callback method 
     57                        var reqHeaders = new Array(); 
     58                        reqHeaders["If-Modified-Since"] = "Sat, 1 Jan 2000 00:00:00 GMT"; 
     59                        var x = new dojo.io.FormBind( 
     60                                { 
     61                                        headers:  reqHeaders, 
     62                                        mimetype: "text/html", 
     63                                        formNode: tfgood, 
     64                                        load:     handler 
     65                                } 
     66                        ); 
     67                        var y = new dojo.io.FormBind( 
     68                                { 
     69                                        headers:  reqHeaders, 
     70                                        mimetype: "text/html", 
     71                                        formNode: tfiebad, 
     72                                        load:     handler 
     73                                } 
     74                        ); 
     75 
     76 
     77                        document.write( "<br><br><b>form.action</b><br>" ); 
     78                        document.write( "This will return an input element named 'action' on both browsers." ); 
     79                        document.write( "<br>" ); 
     80                        document.write( "testform_good.action: " + tfgood.action ); 
     81                        document.write( "<br>" ); 
     82                        document.write( "testform_bad.action: " + tfiebad.action ); 
     83 
     84                        document.write( "<br><br><b>form.getAttribute( 'action' )</b><br>" ); 
     85                        document.write( "This will return an input element named 'action' on IE, but the form action on FF." ); 
     86                        document.write( "<br>" ); 
     87                        document.write( "testform_good.getAttribute( 'action' ): " + tfgood.getAttribute( "action" ) ); 
     88                        document.write( "<br>" ); 
     89                        document.write( "testform_bad.getAttribute( 'action' ): " + tfiebad.getAttribute( "action" ) ); 
     90 
     91                        document.write( "<br><br><b>form.getAttributeNode( 'action' ).value</b><br>" ); 
     92                        document.write( "This will return the form action on both browsers." ); 
     93                        document.write( "<br>" ); 
     94                        document.write( "testform_good.getAttributeNode( 'action' ).value: " + tfgood.getAttributeNode( "action" ).value ); 
     95                        document.write( "<br>" ); 
     96                        document.write( "testform_bad.getAttributeNode( 'action' ).value: " + tfiebad.getAttributeNode( "action" ).value ); 
     97                </script> 
     98        </body> 
     99</html>