X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/bd54ad7dcd1cbf3b37f7822f71ca57b742f00a77..b925718b4bf2dd47a8429f844d0a255ca6e35bd1:/wp-includes/js/jquery/jquery-migrate.js diff --git a/wp-includes/js/jquery/jquery-migrate.js b/wp-includes/js/jquery/jquery-migrate.js index e3538e9c..89437ebe 100644 --- a/wp-includes/js/jquery/jquery-migrate.js +++ b/wp-includes/js/jquery/jquery-migrate.js @@ -1,5 +1,5 @@ /*! - * jQuery Migrate - v1.4.0 - 2016-02-26 + * jQuery Migrate - v1.4.1 - 2016-05-19 * Copyright jQuery Foundation and other contributors */ (function( jQuery, window, undefined ) { @@ -7,7 +7,7 @@ // "use strict"; -jQuery.migrateVersion = "1.4.0"; +jQuery.migrateVersion = "1.4.1"; var warnedAbout = {}; @@ -193,9 +193,11 @@ jQuery.attrHooks.value = { var matched, browser, oldInit = jQuery.fn.init, + oldFind = jQuery.find, oldParseJSON = jQuery.parseJSON, rspaceAngle = /^\s*)([^>]*)$/; @@ -203,45 +205,37 @@ var matched, browser, jQuery.fn.init = function( selector, context, rootjQuery ) { var match, ret; - if ( selector && typeof selector === "string" && !jQuery.isPlainObject( context ) && - (match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) { - // This is an HTML string according to the "old" rules; is it still? - if ( !rspaceAngle.test( selector ) ) { - migrateWarn("$(html) HTML strings must start with '<' character"); - } - if ( match[ 3 ] ) { - migrateWarn("$(html) HTML text after last tag is ignored"); - } - - // Consistently reject any HTML-like string starting with a hash (#9521) - // Note that this may break jQuery 1.6.x code that otherwise would work. - if ( match[ 0 ].charAt( 0 ) === "#" ) { - migrateWarn("HTML string cannot start with a '#' character"); - jQuery.error("JQMIGRATE: Invalid selector string (XSS)"); - } - // Now process using loose rules; let pre-1.8 play too - if ( context && context.context ) { - // jQuery object as context; parseHTML expects a DOM object - context = context.context; - } - if ( jQuery.parseHTML ) { - return oldInit.call( this, - jQuery.parseHTML( match[ 2 ], context && context.ownerDocument || - context || document, true ), context, rootjQuery ); - } - } + if ( selector && typeof selector === "string" ) { + if ( !jQuery.isPlainObject( context ) && + (match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) { - if ( selector === "#" ) { + // This is an HTML string according to the "old" rules; is it still? + if ( !rspaceAngle.test( selector ) ) { + migrateWarn("$(html) HTML strings must start with '<' character"); + } + if ( match[ 3 ] ) { + migrateWarn("$(html) HTML text after last tag is ignored"); + } - // jQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0 - migrateWarn( "jQuery( '#' ) is not a valid selector" ); - selector = []; + // Consistently reject any HTML-like string starting with a hash (gh-9521) + // Note that this may break jQuery 1.6.x code that otherwise would work. + if ( match[ 0 ].charAt( 0 ) === "#" ) { + migrateWarn("HTML string cannot start with a '#' character"); + jQuery.error("JQMIGRATE: Invalid selector string (XSS)"); + } - } else if ( rattrHash.test( selector ) ) { + // Now process using loose rules; let pre-1.8 play too + // Is this a jQuery context? parseHTML expects a DOM element (#178) + if ( context && context.context && context.context.nodeType ) { + context = context.context; + } - // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0 - // Note that this doesn't actually fix the selector due to potential false positives - migrateWarn( "Attribute selectors with '#' must be quoted: '" + selector + "'" ); + if ( jQuery.parseHTML ) { + return oldInit.call( this, + jQuery.parseHTML( match[ 2 ], context && context.ownerDocument || + context || document, true ), context, rootjQuery ); + } + } } ret = oldInit.apply( this, arguments ); @@ -263,6 +257,47 @@ jQuery.fn.init = function( selector, context, rootjQuery ) { }; jQuery.fn.init.prototype = jQuery.fn; +jQuery.find = function( selector ) { + var args = Array.prototype.slice.call( arguments ); + + // Support: PhantomJS 1.x + // String#match fails to match when used with a //g RegExp, only on some strings + if ( typeof selector === "string" && rattrHashTest.test( selector ) ) { + + // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0 + // First see if qS thinks it's a valid selector, if so avoid a false positive + try { + document.querySelector( selector ); + } catch ( err1 ) { + + // Didn't *look* valid to qSA, warn and try quoting what we think is the value + selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) { + return "[" + attr + op + "\"" + value + "\"]"; + } ); + + // If the regexp *may* have created an invalid selector, don't update it + // Note that there may be false alarms if selector uses jQuery extensions + try { + document.querySelector( selector ); + migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] ); + args[ 0 ] = selector; + } catch ( err2 ) { + migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] ); + } + } + } + + return oldFind.apply( this, args ); +}; + +// Copy properties attached to original jQuery.find method (e.g. .attr, .isXML) +var findProp; +for ( findProp in oldFind ) { + if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) { + jQuery.find[ findProp ] = oldFind[ findProp ]; + } +} + // Let $.parseJSON(falsy_value) return null jQuery.parseJSON = function( json ) { if ( !json ) { @@ -631,7 +666,7 @@ jQuery.event.special.ready = { }; var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack, - oldFind = jQuery.fn.find; + oldFnFind = jQuery.fn.find; jQuery.fn.andSelf = function() { migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()"); @@ -639,7 +674,7 @@ jQuery.fn.andSelf = function() { }; jQuery.fn.find = function( selector ) { - var ret = oldFind.apply( this, arguments ); + var ret = oldFnFind.apply( this, arguments ); ret.context = this.context; ret.selector = this.selector ? this.selector + " " + selector : selector; return ret;