Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Exception when element is removed on blur #4417

Closed
Assignees
mgol
Milestone
@paul-f

Description

@paul-f

Description

Running Chrome 73.0.3683.86 on Windows 7 with jQuery 3.4.1.

jQuery tries to read a property of an undefined, causing an exception. This occurs when an element is removed when it loses focus, during a focusout handler, responding to a jQuery triggered blur() event. The three key operations are all performed via jQuery:$(element).blur(), $(element).on("focusout"), $(element).remove().

The exception occurs on line 5467; here is the code up to that line:

dataPriv.set(this,type,saved);// Trigger the native event and capture its result// Support: IE <=9 - 11+// focus() and blur() are asynchronousnotAsync=expectSync(this,type);this[type]();result=dataPriv.get(this,type);if(saved!==result||notAsync){dataPriv.set(this,type,false);}else{result={};}if(saved!==result){// Cancel the outer synthetic eventevent.stopImmediatePropagation();event.preventDefault();returnresult.value;}

In the last line, result is undefined. That is because duringthis[ type ]() (which issues the event), the element is removed, causing jQuery to remove its saved information from dataPriv in cleanData() line 6046:
elem[ dataPriv.expando ] = undefined;

Thus, afterthis[ type ](), result is undefined, it does not equal saved, so thedataPriv.set() of the conditional is executed and result is left undefined. Presumably,result = () needs to be set outside the conditional. This problem is also timing-sensitive -- with the certain break points it may not occur.

This didn't happen in 3.3.1. Note also that jQuery'sblur() must be used, rather than normal JSblur(), in order to go through this code path.

Link to test case

jsfiddle uses 3.3.1, so I didn't set up a test case.

*EDIT by@mgol: I wrapped code pieces in backticks to fix Markdown formatting

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp