Bug 72430 - [test case] all clicked radio-buttons marked as checked
Summary: [test case] all clicked radio-buttons marked as checked
Status: RESOLVED DUPLICATE of bug 100457
Alias: None
Product: konqueror
Classification: Applications
Component: khtml ecma (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-11 23:31 UTC by Hinrich.Sager
Modified: 2005-06-20 14:58 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
test case (4.52 KB, text/html)
2004-01-14 20:53 UTC, Hinrich.Sager
Details
Static Test Case (no errors) (738 bytes, text/html)
2004-02-29 18:39 UTC, Dominic Chambers
Details
Dynamic Test Case (errors!) (927 bytes, text/html)
2004-02-29 18:41 UTC, Dominic Chambers
Details
simple testcase (281 bytes, text/html)
2004-08-03 01:16 UTC, bj
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hinrich.Sager 2004-01-11 23:31:29 UTC
Version:           Unbekannt (using KDE 3.1.4)
Installed from:    SuSE
Compiler:          gcc version 3.3.1 (SuSE Linux)
OS:          Linux (i686) release 2.4.21-99-default

The following code shows, that in some cases a group of dynamicly created radio-buttons is handled like checkboxes: More then one is shown as selected/checked and more then one value is sent. From the 4 shown ways to append them to a parent node only two are working in Konqueror 3.1.4 / 3.2beta but all do it in the current versions of Mozilla and Firebird.

Greetings, Hinrich

URI: http://www.sagernet.de/konqui_test.html

code:
<html><head><title>Konqueror and dynamic Radiobuttons</title>
<script type="text/javascript">
function showRadioAttributes()
{
    var input_element = document.getElementsByTagName("input");

    for(i=0; i<input_element.length; ++i){

        if(input_element[i].checked == true){
            alert("selected is: "
                  + input_element[i].getAttribute("name") + "[" + i + "] "
                  + "value: "
                  + input_element[i].getAttribute("value"));
        }
    }
}

var radio_name  = "RadioGroup";
var value_array = new Array("A", "B", "C");
var parent_id   = "RadioSpace";

function createRadio(grouping_mode)
{
    var parent_node = document.getElementById(parent_id);
    var _fieldset   = document.createElement("fieldset");
    var radio_element, _type, _name, _id, _label, _for, _text;


    for(var i=0; i<value_array.length; ++i){

        // create attributes
        _type            = document.createAttribute("type");
        _type.nodeValue  = "radio";

        _name            = document.createAttribute("name");
        _name.nodeValue  = radio_name;

        _value           = document.createAttribute("value");
        _value.nodeValue = value_array[i];

        _id              = document.createAttribute("id");
        _id.nodeValue    = radio_name+value_array[i];

        // create radio-element and set its attributes
        radio_element    = document.createElement("input");
        radio_element.setAttributeNode(_type);
        radio_element.setAttributeNode(_name);
        radio_element.setAttributeNode(_value);
        radio_element.setAttributeNode(_id);
        radio_element.addEventListener("click", showRadioAttributes, false);

        // create Label
        _text            = document.createTextNode(value_array[i]);
        _label           = document.createElement("label");
        _label.appendChild(_text);
        _for             = document.createAttribute("for");
        _for.nodeValue   = _id;
        _label.setAttributeNode(_for);
        _br = document.createElement("br");

        // different ways to append radio-element an its description to fieldset
        switch(grouping_mode){

          case "same_parent_with_text":
            _fieldset.appendChild(radio_element);
            _fieldset.appendChild(_text);
            _fieldset.appendChild(_br);
            break;

          case "same_parent_with_label":
            _fieldset.appendChild(radio_element);
            _fieldset.appendChild(_label);
            _fieldset.appendChild(_br);
            break;

          case "same_parent_with_label_and_text":
            _fieldset.appendChild(radio_element);
            _fieldset.appendChild(_label);
            _fieldset.appendChild(_text);
            _fieldset.appendChild(_br);
            break;

          case "different_parents":
            new_block = document.createElement("div");
            new_block.appendChild(radio_element);
            new_block.appendChild(_text);
            _fieldset.appendChild(new_block);
            break;
        }//endswitch
    }//endfor

    if (parent_node.hasChildNodes()) {
        parent_node.replaceChild(_fieldset, parent_node.firstChild);
    }
    else{
        parent_node.appendChild(_fieldset);
    }
    //var grouping_mode_text = document.createTextNode(grouping_mode);
    document.getElementById("GroupingModeSpace").firstChild.replaceData(8,100,grouping_mode);
}//endfunction

</script></head>
<body>
<h3>Konqueror has a problem with dynamicly created Radio-Buttons</h3>
<p>Here you can test 4 different ways to add a text-label to radio-buttons created with JavaScript/DOM.
Two of them show a bug in Konqueror 3.1.4: It marks all clicked buttons as selected/checked.
Not only the one who was clicked last.</p>
<div style="background-color:#cccccc; width:600;">
<p>Works: <a href="javascript:createRadio('same_parent_with_text')">
   All to the <b>same parent-node</b> together with <b>text-nodes</b></a></p>
<p>Failes: <a href="javascript:createRadio('same_parent_with_label')">
   All to the <b>same parent-node</b> together with <b>label-nodes</b></a></p>
<p>Works(!): <a href="javascript:createRadio('same_parent_with_label_and_text')">
   All to the <b>same parent-node</b> together with <b>label-nodes <u>and</u> text-nodes</b></a></p>
<p>Failes: <a href="javascript:createRadio('different_parents')">
   Each in a <b>different parent</b> together with <b>text-nodes</b></a></p>
<form name="Testform" action="" method="POST">
<div id="GroupingModeSpace" style="color:#ff0000;">Method: </div>
<div id="RadioSpace"></div>
</form></div></body></html>
Comment 1 Stephan Kulow 2004-01-12 12:11:29 UTC
please attach the test case here
Comment 2 Hinrich.Sager 2004-01-13 23:54:26 UTC
for test case  see http://www.sagernet.de/konqui_test.html
Comment 3 Hinrich.Sager 2004-01-14 20:53:28 UTC
Created attachment 4169 [details]
test case
Comment 4 Dominic Chambers 2004-02-29 18:39:06 UTC
Created attachment 4939 [details]
Static Test Case (no errors)

Here is a highly simplified test case for this bug that you should be more
comprehendable than the original. In this test case the HTML Form is loaded
normally, and presents no problems to Konqueror.
Comment 5 Dominic Chambers 2004-02-29 18:41:56 UTC
Created attachment 4940 [details]
Dynamic Test Case (errors!)

This test case injects the exact same HTML Form into Konqueror, but does so
using JavaScript. The result is that multiple radio selection becomes possible
on the second and fourth sub-tests.
Comment 6 Dominic Chambers 2004-02-29 18:44:11 UTC
I believe the priority of this bug should be downgraded since it is so obscure, and since there are at least two workarounds.
Comment 7 bj 2004-08-03 01:16:22 UTC
Created attachment 6972 [details]
simple testcase

Simpler testcase.
If you dynamically create a form with javascript that contains radiobuttons in
a <fieldset>, and put any tag with an opening and closing tag, like
<span>blah</span> inside the <fieldset> and before the last radiobutton, it
kind of messes up the radiobutton group, so that you can select all buttons at
the same time.
Comment 8 George Staikos 2005-06-20 06:39:20 UTC
SVN commit 427263 by staikos:

Merge webcore fix for replaceChild()
BUG: 100457
BUG: 72430



 M  +4 -0      ChangeLog  
 M  +87 -8     ecma/kjs_binding.cpp  
 M  +25 -5     ecma/kjs_binding.h  
 M  +34 -25    xml/dom_nodeimpl.cpp  
 M  +2 -0      xml/dom_nodeimpl.h  
Comment 9 George Staikos 2005-06-20 14:58:03 UTC
Fix was reverted
Comment 10 George Staikos 2005-06-20 14:58:52 UTC
#100457 has a more clear description of the bug.

*** This bug has been marked as a duplicate of 100457 ***