#10278 closed bug (fixed)
checkboxEl.attr('checked') returns stale value after checkboxEl.click()
Reported by: | IgorMinar | Owned by: | timmywil |
---|---|---|---|
Priority: | high | Milestone: | 1.7 |
Component: | attributes | Version: | 1.6.4rc1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This worked fine in 1.6.2: http://jsfiddle.net/IgorMinar/69fpq/1/
but is broken in 1.6.3 and 1.6.4: http://jsfiddle.net/IgorMinar/69fpq/
Change History (14)
comment:1 Changed 11 years ago by
comment:3 Changed 11 years ago by
Component: | unfiled → attributes |
---|---|
Milestone: | None → 1.7 |
Owner: | set to timmywil |
Priority: | undecided → high |
Status: | new → assigned |
An issue was introduced in the boolHook for non-IE browsers.
comment:4 Changed 11 years ago by
Indeed the issue is in boolHook:
// Hook for boolean attributes boolHook = { get: function( elem, name ) { // Align boolean attributes with corresponding properties // Fall back to attribute presence where some booleans are not supported var attrNode; return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ? name.toLowerCase() : undefined; },
More specifically the check: attrNode.nodeValue !== false
succeeds when it shouldn't because the value is an empty string and not false.
comment:5 Changed 11 years ago by
While #10271 (marked as duplicate of this issue) is caused by an issue in boolHook it is a different issue present in the set
method, while this one is in the get
method.
comment:6 Changed 11 years ago by
@IgorMinar: There is fix for this for 1.7 here: https://github.com/jquery/jquery/commit/2931fa875f7520f87f79c6cff8b1a40d0b4d141a
If there is an issue with set, please provide a test case on http://jsfiddle.net to help us reproduce it.
comment:8 Changed 11 years ago by
I see the milestone is set to 1.7. Is this going to get backported to a 1.6.x release?
comment:9 Changed 11 years ago by
No, but the recommended way to get/set booleans is to get/set the properties with the .prop() method. This fix will be available in 1.7, but the boolHook may be deprecated and eventually removed.
comment:10 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Check for property support in the boolHook before falling back to attribute node. Fixes #10278.
Changeset: daeb66504565d3b95dbd6310778def4166044750
comment:12 Changed 11 years ago by
CHECKBOXEL.ATTR('CHECKED')is still return "checked" for checked and "undefined" for unchecked checkbox
comment:13 Changed 11 years ago by
I am having the same issue:
CHECKBOXEL.ATTR('CHECKED')is still return "checked" for checked and "undefined" for unchecked checkbox
any updates?
comment:14 Changed 11 years ago by
That is the desired behavior, but I recommend using http://api.jquery.com/prop to check the checked value.
#10274 is a duplicate of this ticket.