Side navigation
#13474 closed bug (notabug)
Opened February 18, 2013 11:33PM UTC
Closed February 19, 2013 02:10PM UTC
Last modified February 19, 2013 06:01PM UTC
Boolean attribute (such as 'selected') cannot be set back after reset with Firefox
Reported by: | Michel (R) | Owned by: | Michel (R) |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | attributes | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Firefox version: 18.0.2
If I use jQuery to set the 'selected' attribute on an option element, it works.
However if I reset this attribute, then the set method doesn't work anymore.
It works normally under IE (8).
The problem is in this part:
removeAttr: function( elem, value ) { ... } else { elem[ propName ] = false; // <<==== }
The set methods is something like:
set: function( elem, value, name ) { ... elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
Which in our case does:
elem.setAttribute(name, name)
If elem[name] = false was called before, it doesn't work anymore under Firefox.
Apparently, the following line seems to fix the problem under this version of Firefox and IE8 but I cannot test with other browsers nor did I try other possibilities:
elem[name] = name;
Attachments (0)
Change History (4)
Changed February 19, 2013 12:21AM UTC by comment:1
owner: | → Michel (R) |
---|---|
status: | new → pending |
Changed February 19, 2013 09:39AM UTC by comment:2
_comment0: | Hello, \ \ Yes I wanted to prepare a test case but it was kind of late (after midnight my time). Thank you for the fiddle link. \ \ Here it is: \ \ http://jsfiddle.net/3UwC8/ \ \ When loaded, both options should be selected. On my Firefox 18.0.2, only the first one is. \ \ → 1361267143671369 |
---|
Hello,
Yes I wanted to prepare a test case but it was kind of late (after midnight my time). Thank you for the fiddle link.
Here it is:
When loaded, both options should be selected. On my Firefox 18.0.2, only the first one is.
Changed February 19, 2013 02:10PM UTC by comment:3
component: | unfiled → attributes |
---|---|
resolution: | → notabug |
status: | pending → closed |
Please use .prop
to update the dynamic state of elements: http://jsfiddle.net/3UwC8/2/
As of version 1.9, we no longer guarantee any user-visible effects of adding or removing boolean attributes, so they may vary between browsers. Also note that the migrate plugin both restores and warns about the old behavior: http://jsfiddle.net/3UwC8/3/
Changed February 19, 2013 06:01PM UTC by comment:4
Thanks, I see.
This code was actually part of a 3rd party jQuery UI widget, so this means that I should warn the author that his plugin should be fixed.
Thanks for the advices!
Thanks for taking the time to contribute to the jQuery project! Treatment of boolean attributes has changed recently, and
.attr
and.prop
can interact in non-obvious ways with respect to them, so please provide a complete reduced test case on jsFiddle to help us assess your ticket.