Make WordPress Core

Ticket #22975: 22975.patch

File 22975.patch, 7.5 KB (added by ocean90, 10 years ago)
  • wp-includes/js/jquery/jquery-migrate.js

     
    11/*!
    2  * jQuery Migrate - v1.0.0 - 2013-01-14
     2 * jQuery Migrate - v1.1.0 - 2013-01-31
    33 * https://github.com/jquery/jquery-migrate
    44 * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT
    55 */
     
    1515// Set to true to prevent console output; migrateWarnings still maintained
    1616// jQuery.migrateMute = false;
    1717
     18// Show a message on the console so devs know we're active
     19if ( !jQuery.migrateMute && window.console && console.log ) {
     20        console.log("JQMIGRATE: Logging is active");
     21}
     22
     23// Set to false to disable traces that appear with warnings
     24if ( jQuery.migrateTrace === undefined ) {
     25        jQuery.migrateTrace = true;
     26}
     27
    1828// Forget any warnings we've already given; public
    1929jQuery.migrateReset = function() {
    2030        warnedAbout = {};
     
    2737                jQuery.migrateWarnings.push( msg );
    2838                if ( window.console && console.warn && !jQuery.migrateMute ) {
    2939                        console.warn( "JQMIGRATE: " + msg );
     40                        if ( jQuery.migrateTrace && console.trace ) {
     41                                console.trace();
     42                        }
    3043                }
    3144        }
    3245}
     
    6679
    6780
    6881var attrFn = {},
    69         attr = jQuery.attr,
     82        oldAttr = jQuery.attr,
    7083        valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
    7184                function() { return null; },
    7285        valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
     
    8396        var lowerName = name.toLowerCase(),
    8497                nType = elem && elem.nodeType;
    8598
    86         if ( pass ) {
     99        // Since pass is used internally, we only warn and shim for new jQuery
     100        // versions where there isn't a pass arg in the formal params
     101        if ( pass && oldAttr.length < 4 ) {
    87102                migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
    88103                if ( elem && !rnoAttrNodeType.test( nType ) && jQuery.isFunction( jQuery.fn[ name ] ) ) {
    89104                        return jQuery( elem )[ name ]( value );
    90105                }
    91106        }
    92107
    93         // Warn if user tries to set `type` since it breaks on IE 6/7/8
    94         if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) ) {
     108        // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking
     109        // for disconnected elements we don't warn on $( "<button>", { type: "button" } ).
     110        if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) {
    95111                migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
    96112        }
    97113
     
    131147
    132148                // Warn only for attributes that can remain distinct from their properties post-1.9
    133149                if ( ruseDefault.test( lowerName ) ) {
    134                         migrateWarn( "jQuery.fn.attr(" + lowerName + ") may use property instead of attribute" );
     150                        migrateWarn( "jQuery.fn.attr('" + lowerName + "') may use property instead of attribute" );
    135151                }
    136152        }
    137153
    138         return attr.call( jQuery, elem, name, value );
     154        return oldAttr.call( jQuery, elem, name, value );
    139155};
    140156
    141157// attrHooks: value
     
    146162                        return valueAttrGet.apply( this, arguments );
    147163                }
    148164                if ( nodeName !== "input" && nodeName !== "option" ) {
    149                         migrateWarn("property-based jQuery.fn.attr('value') is deprecated");
     165                        migrateWarn("jQuery.fn.attr('value') no longer gets properties");
    150166                }
    151167                return name in elem ?
    152168                        elem.value :
     
    158174                        return valueAttrSet.apply( this, arguments );
    159175                }
    160176                if ( nodeName !== "input" && nodeName !== "option" ) {
    161                         migrateWarn("property-based jQuery.fn.attr('value', val) is deprecated");
     177                        migrateWarn("jQuery.fn.attr('value', val) no longer sets properties");
    162178                }
    163179                // Does not return so that setAttribute is also used
    164180                elem.value = value;
     
    168184
    169185var matched, browser,
    170186        oldInit = jQuery.fn.init,
    171         // Note this does NOT include the # XSS fix from 1.7!
    172         rquickExpr = /^(?:.*(<[\w\W]+>)[^>]*|#([\w\-]*))$/;
     187        oldParseJSON = jQuery.parseJSON,
     188        // Note this does NOT include the #9521 XSS fix from 1.7!
     189        rquickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*|#([\w\-]*))$/;
    173190
    174191// $(html) "looks like html" rule change
    175192jQuery.fn.init = function( selector, context, rootjQuery ) {
     
    195212};
    196213jQuery.fn.init.prototype = jQuery.fn;
    197214
     215// Let $.parseJSON(falsy_value) return null
     216jQuery.parseJSON = function( json ) {
     217        if ( !json && json !== null ) {
     218                migrateWarn("jQuery.parseJSON requires a valid JSON string");
     219                return null;
     220        }
     221        return oldParseJSON.apply( this, arguments );
     222};
     223
    198224jQuery.uaMatch = function( ua ) {
    199225        ua = ua.toLowerCase();
    200226
     
    274300
    275301
    276302var rscriptType = /\/(java|ecma)script/i,
    277         oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,
    278         oldFragment = jQuery.buildFragment;
     303        oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack;
    279304
    280305jQuery.fn.andSelf = function() {
    281306        migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
     
    332357        };
    333358}
    334359
    335 jQuery.buildFragment = function( elems, context, scripts, selection ) {
    336         var ret,
    337                 warning = "jQuery.buildFragment() is deprecated";
    338 
    339         // Set context per 1.8 logic
    340         context = context || document;
    341         context = !context.nodeType && context[0] || context;
    342         context = context.ownerDocument || context;
    343 
    344         try {
    345                 ret = oldFragment.call( jQuery, elems, context, scripts, selection );
    346 
    347         // jQuery < 1.8 required arrayish context; jQuery 1.9 fails on it
    348         } catch( x ) {
    349                 ret = oldFragment.call( jQuery, elems, context.nodeType ? [ context ] : context[ 0 ], scripts, selection );
    350 
    351                 // Success from tweaking context means buildFragment was called by the user
    352                 migrateWarn( warning );
    353         }
    354 
    355         // jQuery < 1.9 returned an object instead of the fragment itself
    356         if ( !ret.fragment ) {
    357                 migrateWarnProp( ret, "fragment", ret, warning );
    358                 migrateWarnProp( ret, "cacheable", false, warning );
    359         }
    360 
    361         return ret;
    362 };
    363 
    364360var eventAdd = jQuery.event.add,
    365361        eventRemove = jQuery.event.remove,
    366362        eventTrigger = jQuery.event.trigger,
     
    386382}
    387383
    388384// Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
    389 migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );
     385if ( jQuery.event.dispatch ) {
     386        migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );
     387}
    390388
    391389// Support for 'hover' pseudo-event and ajax event warnings
    392390jQuery.event.add = function( elem, types, handler, data, selector ){
  • wp-includes/script-loader.php

     
    107107        ) );
    108108
    109109        $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), false, 1 );
    110        
     110
    111111        $scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array('jquery'), false, 1 );
    112112        did_action( 'init' ) && $scripts->localize( 'heartbeat', 'heartbeatSettings',
    113113                apply_filters( 'heartbeat_settings', array() )
     
    132132        // jQuery
    133133        $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ) );
    134134        $scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.9.0' );
    135         $scripts->add( 'jquery-migrate', '/wp-includes/js/jquery/jquery-migrate.js', array(), '1.0.0' );
     135        $scripts->add( 'jquery-migrate', '/wp-includes/js/jquery/jquery-migrate.js', array(), '1.1.0' );
    136136
    137137        // full jQuery UI
    138138        $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui/jquery.ui.core.min.js', array('jquery'), '1.9.2', 1 );