On Dec 15, 11:21 am, John Resig <jere...@gmail.com> wrote: > Hmm, I don't remember the bug off-hand but here's the reproduction: > Failing:http://ejohn.org/files/bugs/selected/ > Passing:http://ejohn.org/files/bugs/selected/fixed.html
Ah, I see. The description in the source is misleading. Note that this only happens before the page is done loading (if you fire the check in window.onload it works fine). Also, an <option> may exist in an <optgroup> element, so simply accessing parentNode.selectedIndex isn't sufficient. How about this: // In Safari, if no option is explicitly selected and the first // option gets selected by default, this option will report // selected==false _while the page is still loading_. Accessing the // containing select element causes the option to set its // selected state correctly. Since options may be nested in // <optgroup> elements, access two levels up just to be safe. // Simply accessing the .selectedIndex property even if it doesn't // exist shouldn't cause a problem in any browsers. // http://ejohn.org/files/bugs/selected/ if ( name == "selected" && elem.parentNode ) { elem.parentNode.selectedIndex; if (elem.parentNode.parentNode) { elem.parentNode.parentNode.selectedIndex; } } > > var attr = elem.getAttribute(name,2); > Unfortunately that's not the case - I know that in older versions of > Opera if you tried to use the , 2 it would straight out crash the > browser - which is why we had to do the extra check. It's silly, of > course, since the extra argument shouldn't do anything. Never seen that problem, and I'm too lazy to look for it. I'll trust you on that one. May want to add a note to that effect in the source. Explanatory documentation is valuable. Matt Kruse -- You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-...@googlegroups.com. To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.