Skip to main content

Bug Tracker

Side navigation

#10278 closed bug (fixed)

Opened September 14, 2011 03:35PM UTC

Closed September 19, 2011 07:43PM UTC

Last modified March 08, 2012 03:01PM UTC

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/

Attachments (0)
Change History (14)

Changed September 14, 2011 03:47PM UTC by timmywil comment:1

#10274 is a duplicate of this ticket.

Changed September 14, 2011 03:48PM UTC by timmywil comment:2

#10271 is a duplicate of this ticket.

Changed September 14, 2011 03:51PM UTC by timmywil comment:3

component: unfiledattributes
milestone: None1.7
owner: → timmywil
priority: undecidedhigh
status: newassigned

An issue was introduced in the boolHook for non-IE browsers.

Changed September 14, 2011 04:29PM UTC by IgorMinar comment:4

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.

Changed September 14, 2011 04:37PM UTC by IgorMinar comment:5

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.

Changed September 14, 2011 06:38PM UTC by timmywil comment:6

@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.

Changed September 14, 2011 06:40PM UTC by timmywil comment:7

#10280 is a duplicate of this ticket.

Changed September 15, 2011 10:56PM UTC by anonymous comment:8

I see the milestone is set to 1.7. Is this going to get backported to a 1.6.x release?

Changed September 16, 2011 01:52AM UTC by timmywil comment:9

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.

Changed September 19, 2011 07:43PM UTC by timmywil comment:10

resolution: → fixed
status: assignedclosed

Check for property support in the boolHook before falling back to attribute node. Fixes #10278.

Changeset: daeb66504565d3b95dbd6310778def4166044750

Changed October 06, 2011 01:25PM UTC by dmethvin comment:11

#10434 is a duplicate of this ticket.

Changed November 15, 2011 07:47AM UTC by anonymous comment:12

CHECKBOXEL.ATTR('CHECKED')is still return "checked" for checked and "undefined" for unchecked checkbox

Changed November 17, 2011 01:29AM UTC by anonymous comment:13

I am having the same issue:

CHECKBOXEL.ATTR('CHECKED')is still return "checked" for checked and "undefined" for unchecked checkbox

any updates?

Changed November 17, 2011 01:31AM UTC by timmywil comment:14

That is the desired behavior, but I recommend using http://api.jquery.com/prop to check the checked value.