Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#11663 closed bug (patchwelcome)

Removing an event target during a change event throws NOT_FOUND_ERR

Reported by: Sebmaster Owned by: Sebmaster
Priority: low Milestone: None
Component: event Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

If you bind an event handler via on() on a change event and remove the event target in the event handler via empty() jQuery throws a "Uncaught Error: NOT_FOUND_ERR: DOM Exception 8".

Testcast is at: http://jsfiddle.net/KRvFk/

If you replace the call to empty() with a .innerHTML = it behaves as expected.

Testcase: http://jsfiddle.net/KRvFk/1/

Change History (9)

comment:1 Changed 7 years ago by sindresorhus

Component: unfiledevent
Owner: set to Sebmaster
Priority: undecidedlow
Status: newpending

Which browsers are you seeing the problem in?

comment:2 Changed 7 years ago by Sebmaster

Status: pendingnew

The error occurs on Chrome 18.0.1025.162 m and Chrome 20.0.1119.0 canary.

It does not occur in Internet Explorer 9 and 10 and Firefox 10.0.0.2.

comment:3 Changed 7 years ago by dmethvin

Status: newpending

I do not see an error in Chrome 18.0.1025.162 (What does the "m" mean?)

Can you try it in Incognito mode and see if perhaps an extension is messing things up?

comment:4 in reply to:  3 Changed 7 years ago by Sebmaster

Status: pendingnew

Replying to dmethvin:

I do not see an error in Chrome 18.0.1025.162 (What does the "m" mean?)

Can you try it in Incognito mode and see if perhaps an extension is messing things up?

Did you type something into the text box and press enter?

I tried in Inkognito mode, made sure no extensions are running. Even tested on another computer, same chrome build, same error.

comment:5 Changed 7 years ago by dmethvin

Status: newopen

Interesting. If you click away from the box, no error; that is what I was doing. If you hit Enter, there is the error.

This looks like a Chrome bug. If you set Chrome to break on errors, you can see that elem.firstChild is null, yet Chrome enters the loop inside .empty() and errors when trying to run elem.removeChild( null ). http://i.imgur.com/LjOuG.png

Not sure whether/when we'll fix it, but it should be reported to Chrome.

comment:6 Changed 7 years ago by sindresorhus

Looks like it has already been reported back in november: http://code.google.com/p/chromium/issues/detail?id=104397

comment:7 Changed 7 years ago by dmethvin

Resolution: patchwelcome
Status: openclosed

Other than the dreaded try-catch, which isn't really a fix, I don't think there is a way for us to fix this. If Chrome says there's a .firstChild it should let us remove that child without complaint.

comment:8 Changed 7 years ago by dmethvin

#12505 is a duplicate of this ticket.

comment:9 Changed 6 years ago by mastah

Problem seem to be corrected with jquery 1.9.x

http://jsfiddle.net/Mastah/PdtKD/

Test that under chrome with jquery 1.8.3 and 1.9.0

Just click append, then focus on input and press enter. It will properly work under jquery 1.9.0, but will fail under 1.8.3

Note: See TracTickets for help on using tickets.