Skip to content

Triggering after an alert() in an event handler results in a JS error #5459

Closed
@AllanJard

Description

Description

It appears that if I trigger a blur event, immediately after an alert() inside a click event handler, it results in an error:

Uncaught TypeError: saved.slice is not a function

This is happening in jQuery 3.7.1 and 4.0.0-beta. But not in 3.5.1. I wonder if this issue might be related.

Link to test case

The way to reproduce this is quite simple:

    $('button').on('click', function (e) {
      alert('Hello');
      
      $(this).trigger('blur');
    })

https://jsbin.com/vuquzepidi/edit?html%2Cjs%2Coutput=

I've found that if I use console.log instead of alert() it works just fine. Also if I put the trigger into a setTimeout it works just fine. Likewise if I change it to trigger a focus event it works. I did try a focus before the blur, wondering if the alert might cause the button to loose focus, but no change, and even if it did, I would have expected an error.

Apologies, I haven't yet dug into the code to see what might be happening - I can see in the debugger that saved is true, but I've not looked to see why that is yet.

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions