You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 during this[ 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, after this[ type ](), result is undefined, it does not equal saved, so the dataPriv.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's blur() must be used, rather than normal JS blur(), 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