Skip to content

Update one.xml - Fixed ambiguity in sample code string #489

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

Closed
wants to merge 1 commit into from
Closed

Update one.xml - Fixed ambiguity in sample code string #489

wants to merge 1 commit into from

Conversation

tomfuertes
Copy link
Contributor

Text on selector is ambigious to it's actual functionality. Changed from sounding like "the click on #foo had to be the first click in the document" to "the first click on #foo in the document"

jsfiddle for playground/proof: http://jsfiddle.net/B3zNn/1/

Text on selector is ambigious to it's actual functionality.

Changed from sounding like "the click on #foo had to be the first click in the document" to "the first click on #foo"

jsfiddle for playground/proof: http://jsfiddle.net/B3zNn/1/
@tomfuertes
Copy link
Contributor Author

Totally missed the text before this too (in quote below) - sounds like the original text was intentional, but that the functionality in the jsfiddle differs... Not sure if this is a jQuery bug request and/or a doc change

The second two forms, introduced in jQuery 1.7, are identical to .on() except that the handler is removed after the first time the event occurs at the delegated element, whether the selector matched anything or not.

@scottgonzalez
Copy link
Member

I think this is actually a docs bug. @dmethvin Can you confirm the intended behavior?

@dmethvin
Copy link
Member

dmethvin commented May 9, 2014

The docs are correct as-is. The text in the body clarify what is going on if the example isn't totally clear. If there is no #foo in the document the handler will still be removed after the first click.

Even if we tried to handle this by waiting for a #foo to exist, there's no guarantee that's the right behavior. Imagine the same situation with .bar where it's less clear whether element(s) should exist or not.

@dmethvin dmethvin closed this May 9, 2014
@scottgonzalez
Copy link
Member

@dmethvin The fiddle says otherwise; tested with 1.7.2, 1.8.3, 1.9.1, 1.10.1, 1.11.0, and 2.x.

@scottgonzalez scottgonzalez reopened this May 9, 2014
@dmethvin
Copy link
Member

dmethvin commented May 9, 2014

Ok then I'll need to puzzle it out later.

@tomfuertes
Copy link
Contributor Author

Posting a more comprehensive fiddle for ref per Dave's "if #foo doesn't exist" use case: http://jsfiddle.net/B3zNn/10/

@gibson042
Copy link
Member

From its introduction to its current implementation, .one has always unregistered the handler immediately before invoking it (and thus has never unregistered the handler when a delegated selector failed to match). I vote for using this PR to update the documentation and example, rather than closing it and rewriting the method. 😉

@kswedberg
Copy link
Member

Merged this in because it seems like the minor change to the docs is preferable to a possibly breaking change to the code. @dmethvin, let me know if you think anything else needs to be done here.

@tomfuertes
Copy link
Contributor Author

Per @gibson042, I think the doc fix is preferred. Made the preceding paragraph to this fix consistent per the second comment here in #519

@kswedberg
Copy link
Member

Thanks, Tom. We should be all good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

6 participants