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

Event: Only attach events to objects that accept data - for real#4558

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mgol merged 1 commit intojquery:masterfrommgol:add-data-fix
Dec 9, 2019

Conversation

mgol
Copy link
Member

@mgolmgol commentedDec 3, 2019
edited
Loading

Summary

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 assumeddataPriv.get( elem ) returns a falsy
value for anelem that doesn't accept data but that's not the case - we get
an empty object then. The check was changed to useacceptData directly.

Fixesgh-4397

It's funny that this has been the behavior for at least the past few years so this code has been wrong for a long time. 😱

We'll also need to CP that to3.x-stable

+2 bytes

Checklist

@mgolmgol added this to the4.0.0 milestoneDec 3, 2019
@mgolmgol self-assigned thisDec 3, 2019
@mgolmgol modified the milestones:4.0.0,3.5.0Dec 3, 2019
@dmethvin
Copy link
Member

Wow, this does go back a ways!

QUnit.test( ".on('focus', fn) on a text node doesn't throw", function( assert ) {
assert.expect( 1 );

jQuery( "<div></div>text<span></span>" )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'd prefer something more obvious here such asjQuery( document.createTextNode("text") ), but this works as long as the behavior doesn't change (do we test that, though?).

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@gibson042 Your suggestion looks good to me. What do you mean by "as long as the behavior doesn't change", though? What behavior?

There was a check in jQuery.event.add that was supposed to make it a noopfor objects that don't accept data like text or comment nodes. The problem wasthe check was incorrect: it assumed `dataPriv.get( elem )` returns a falsyvalue for an `elem` that doesn't accept data but that's not the case - we getan empty object then. The check was changed to use `acceptData` directly.Fixesjquerygh-4397
@mgolmgol merged commitd5c505e intojquery:masterDec 9, 2019
@mgolmgol deleted the add-data-fix branchDecember 9, 2019 18:50
mgol added a commit that referenced this pull requestDec 9, 2019
There was a check in jQuery.event.add that was supposed to make it a noopfor objects that don't accept data like text or comment nodes. The problem wasthe check was incorrect: it assumed `dataPriv.get( elem )` returns a falsyvalue for an `elem` that doesn't accept data but that's not the case - we getan empty object then. The check was changed to use `acceptData` directly.(cherry picked fromd5c505e)Fixesgh-4397Closesgh-4558
@locklockbot locked asresolvedand limited conversation to collaboratorsJun 24, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@gibson042gibson042gibson042 approved these changes

@dmethvindmethvindmethvin approved these changes

Assignees

@mgolmgol

Labels
Milestone
3.5.0
Development

Successfully merging this pull request may close these issues.

Bug with .focus and text nodes in 3.4
3 participants
@mgol@dmethvin@gibson042

[8]ページ先頭

©2009-2025 Movatter.jp