New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug with .focus and text nodes in 3.4 #4397
Comments
What a well-structured issue. Test cases and everything. Thanks! We can look into whether the call stack error is avoidable. |
This is like a holy trinity of nightmare scenarios. There aren't a lot of ways to get a text node into a set, but The event system does not want or expect the target of an event to be a text node. It's not supposed to happen, and for the few cases where browsers erroneously did it in the past we fixed the issue when the browser created it. That fix wouldn't work in this case anyway 1) because those text nodes are orphans and I'll also point out that triggering focus on three nodes in succession as done in this test case is pretty strange. When the whole thing is done only one will have focus, I assume it's the last one but the async focus behavior of IE may do something different. All that said, it's worth examining the new 3.4 code to see what is causing the error. Blowing out the stack is never a fun outcome. |
FWIW, I encounter this error in regards to |
Gents, Any idea when this might be resolved? I thought I saw somewhere a fix was scheduled for 3.4.2, but I see the milestone is 3.5. Thanks |
If you don't care about the text or comment nodes, just add |
@dmethvin - It's not my code. jQ is required for a library I'm using in a PHP webapp. I wouldn't know where to start as I'm a PHP guy. |
Normal Github etiquette is to either move the ball forward with a fix of some kind or, if you have no ability to do that, simply vote on the original ticket. Conversations like this notify thousands of people who are watching the repo, so it's rude to them to make "how soon will this be fixed" posts. |
It's not triggering focus on three nodes but attaching a focus handler on them, using the deprecated event shortcut form. |
There was a check in jQuery.event.add that made it a noop for objects that don't accept data like text or comment nodes. Fixes jquerygh-4397
PR: #4558 This issue has uncovered a bug that has been in the code for a long time! |
There was a check in jQuery.event.add that was supposed to make it a noop for objects that don't accept data like text or comment nodes. The problem was the check was incorrect: it assumed `dataPriv.get( elem )` returns a falsy value for an `elem` that doesn't accept data but that's not the case - we get an empty object then. The check was changed to use `acceptData` directly. Fixes jquerygh-4397
There was a check in jQuery.event.add that was supposed to make it a noop for objects that don't accept data like text or comment nodes. The problem was the check was incorrect: it assumed `dataPriv.get( elem )` returns a falsy value for an `elem` that doesn't accept data but that's not the case - we get an empty object then. The check was changed to use `acceptData` directly. Fixes jquerygh-4397
There was a check in jQuery.event.add that was supposed to make it a noop for objects that don't accept data like text or comment nodes. The problem was the check was incorrect: it assumed `dataPriv.get( elem )` returns a falsy value for an `elem` that doesn't accept data but that's not the case - we get an empty object then. The check was changed to use `acceptData` directly. Fixes gh-4397 Closes gh-4558
There was a check in jQuery.event.add that was supposed to make it a noop for objects that don't accept data like text or comment nodes. The problem was the check was incorrect: it assumed `dataPriv.get( elem )` returns a falsy value for an `elem` that doesn't accept data but that's not the case - we get an empty object then. The check was changed to use `acceptData` directly. (cherry picked from d5c505e) Fixes gh-4397 Closes gh-4558
Description
There's a new breaking change in 3.4 when you attempt to call
.focus(fn)
on a selector containing a text node.Consider the following:
in v3.3.1 this is all fine, but in v3.4.0 and v3.4.1 you get
Uncaught RangeError: Maximum call stack size exceeded
Of note, no one would do this on purpose, as it doesn't make sense, and even this example is a bit contrived (actual case I encountered at least had form elements), but given various libraries out of my control, it managed to happen for me.
This is the case in question: gitana/alpaca#705
This is clearly outside the boundaries of normal usage, however, is it possible for the
.focus(fn)
could have some checks to not fail quite so critically?According to the jQuery function docs it sounds like text nodes should generally be tolerated?
Link to test case
In this jsfiddle with v3.4.1, it produces an error
https://jsfiddle.net/anneb574/r2pambcz/1/
but this jsfiddle with v3.3.1 it doesn't
https://jsfiddle.net/anneb574/r2pambcz/3/
The text was updated successfully, but these errors were encountered: