-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Description
Hello jquery community,
First of all:
Here's the demo
All relevant output show's up in the browser's console.
Here's a screenshot that shows the line in jQuery where the problem happens.
(You can see that elem is a document-fragment)

Source of the demo
Can be found here
Situation
You have a delegate click event handler that targets elements by a specific attribute
$(document).on('click', '[some-attribute]', function() {...});
You have a custom element that uses html5 templates to create a simple list of items.
Each item has a button to remove the parent item itself from the list.
What happens
The click on a items button removes the element before the event reaches the jQuery event handler. At the time the event arrives, the item has been removed and placed in a document fragment. Now jQuery tests the event selector on the document fragment and that fails of course.
I guess the fix would simply be to check if the element tested on the selector actually has a attribute api?