Closed Bug 977034 Opened 10 years ago Closed 4 years ago

Checkbox doesn't toggle on click event when inside of document fragment

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

46 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1610821

People

(Reporter: spamfaenger, Assigned: yrliou)

References

Details

(Whiteboard: [tw-dom])

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11

Steps to reproduce:

Created a document fragment that contains a checkbox, sent it a click event, and expected the checkbox to be checked afterwards.

See http://jsfiddle.net/4sDMN/


Actual results:

Doesn't work in Firefox where the state of the checkbox isn't toggled like it should be.


Expected results:

It should be toggled, like Safari and Blink do.

This is important as this issue comes up most often during unit testing, where document fragments are used to test code that interacts with UI elements in isolation from the dom, which is used to display test results. Document fragments bring isolation and speed to these tests.
Component: Untriaged → Event Handling
Product: Firefox → Core
I'd like to add that this is also very surprising if you configure a document fragment in code to then insert into the dom. In other browsers it works as expected, while FF will just discard the checked state.
This is still happening as of Firefox (developer edition) 46.0a2 (2016-02-29).

Reproduction should be quite simple due to the provided code:

```
var cb = $("<input class='cb' type='checkbox' />")
//cb.prop('checked', true); 
cb.click()

if (cb.prop('checked')){
    alert("checkbox clicked correctly!"); 
}else{
    alert("fail!"); 
}
```
which can be quite easily test run on jsfiddle http://jsfiddle.net/4sDMN/ .


Are there any plans to fix this eventually? Do you need more information? More prodding?
Version: 12 Branch → 46 Branch
Confirmed:  
Version 	45.0
Build ID 	20160303134406
User Agent 	Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
Version 	48.0a1
Build ID 	20160314030215
Status: UNCONFIRMED → NEW
Ever confirmed: true
Sure, once someone has time to fix this.
Gecko is open source so you could download the source code and fix this ;)

But let me see if I can find someone to look at this.
Whiteboard: [tw-dom]
Assignee: nobody → joliu
I can confirm this bug is still present in Firefox 57.
Component: Event Handling → User events and focus handling

More spec clarity, and tests, for this issue landed in https://github.com/whatwg/html/pull/5335 and https://github.com/web-platform-tests/wpt/pull/22075 .

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.