Skip to content

Lib: Update error-placement.js to jQuery 1.11.1 #1158

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

Conversation

tractorcow
Copy link
Collaborator

See #1157

@tractorcow tractorcow deleted the jquery-1-11 branch June 10, 2014 20:21
@Krinkle
Copy link

Krinkle commented Jun 17, 2014

Hm.. I'm curious why this was needed (fearing what I may have to change in my own code). Which change in jQuery is this accommodating for?

http://blog.jquery.com/2014/01/24/jquery-1-11-and-2-1-released/

@tractorcow
Copy link
Collaborator Author

It looks as though previous behaviour of contents allowed for method arguments, but the current docs specify this method currently does not take any. Perhaps it was relying on an undocumented feature?

It could have been a regression from prior to 1.11.1

@Krinkle
Copy link

Krinkle commented Jun 17, 2014

From at least jQuery 1.4 up to and including 1.11.1, the jQuery#contents method is implemented as part of a loop generating multiple methods. It still includes a selector arguments even now (which is indeed an documented feature and just a side-effect of the implementation re-using part of the code, should not be relied upon).

However, undocumented or not, from what I see it's been there since at least jQuery 1.4 and is still there in jQuery 1.11.1:

    contents: function( elem ) {
        return jQuery.nodeName( elem, "iframe" ) ?
            elem.contentDocument || elem.contentWindow.document :
            jQuery.makeArray( elem.childNodes );
    }
}, function( name, fn ) {
    jQuery.fn[ name ] = function( until, selector ) {
        var ret = jQuery.map( this, fn, until );

        if ( !runtil.test( name ) ) {
            selector = until;
        }

        if ( selector && typeof selector === "string" ) {
            ret = jQuery.filter( selector, ret );
        }

And testing shows it still seems to works:

$('body').contents();
> [ <pre> ]
$('body').contents( 'div' );
> []
$('body').contents( 'pre' );
> [ <pre> ]

@Krinkle
Copy link

Krinkle commented Jun 17, 2014

Anyway, it makes sense now. The argument is not officially supported and therefore shouldn't be used.

I thought maybe the issue was more subtle (eg. :not() no longer being supported in some cases, or something like that). Just wanted to know exactly what part of the old code you were moving away from, so that I can look for it in my own code.

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants