On 7/11/06, Chris Lear wrote:

Are you sure it's a Firefox bug? The way the builder code works is very
strange... to create an option element, it seems to create a select
element, put the option element into it, then fetch the option out of
that select element again. The result is that the option is *always*
selected. I think it's because firefox is treating it as the only
element in the select list, which means it must be selected. [When I run
your code, the last element in the list is selected, rather than the
first. If I debug the value of the "selected" attribute, it's "selected"
for all of them]

Are you speaking from the code at
http://bugzilla.mozilla.org/show_bug.cgi?id=300016#c10 ?

How do you debug +the value of the "selected" attribute+ ? See below...


This code, which is pure DOM and has none of the builder weirdness, but
sets attributes in the same way, works in Firefox:

var dr=document.createElement("select");
var op=document.createElement("option");
op.appendChild(document.createTextNode("any"));
dr.appendChild(op);
op=document.createElement("option");
op.appendChild(document.createTextNode("all"));

op["selected"]="selected"; // <- attribute set here

The last line ^^^^ is not using the DOM API, but I agree that your
solutions works in Firefox. Nevertheless, I suspect it is not for the
good reason: if I inspect the resulting DOM Tree (with Firefox DOM
Inspector), your solution gives:

<select>
 <option>any</option>
 <option>all</option>
 <option>none</option>
</select>

while the solution given in
http://bugzilla.mozilla.org/show_bug.cgi?id=300016#c10 gives:

<select>
 <option value="any">any</option>
 <option selected="selected" value="all">all</option>
 <option value="none">none</option>
</select>

Back to your comment
https://bugzilla.mozilla.org/show_bug.cgi?id=300016#c11, the DOM
Engine from Firefox should not make any difference within your
solution and mine, or should it?

--
Marc-Olivier BERNARD
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to