WordPress.org

Make WordPress Core

Changeset 23182


Ignore:
Timestamp:
12/17/2012 08:08:08 PM (6 years ago)
Author:
nacin
Message:

Update jQuery Migrate plugin to latest, fixing .toggle(boolean) usage. see #22975.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/jquery/jquery-migrate.js

    r23180 r23182  
    11/*!
    2  * jQuery Migrate - v1.0.0b1 - 2012-12-16
     2 * jQuery Migrate - v1.0.0pre - 2012-12-17
    33 * https://github.com/jquery/jquery-migrate
    44 * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT
     
    1010// Use Uglify to do conditional compilation of warning messages;
    1111// the minified version will set this to false and remove dead code.
    12 if ( typeof JQMIGRATE_WARN === "undefined" ) {
     12if ( typeof window.JQMIGRATE_WARN === "undefined" ) {
    1313    window.JQMIGRATE_WARN = true;
    1414}
     
    2727
    2828function migrateWarn( msg) {
    29     if ( JQMIGRATE_WARN ) {
     29    if ( window.JQMIGRATE_WARN ) {
    3030        if ( !warnedAbout[ msg ] ) {
    3131            warnedAbout[ msg ] = true;
     
    3939
    4040function migrateWarnProp( obj, prop, value, msg ) {
    41     if ( JQMIGRATE_WARN && Object.defineProperty ) {
     41    if ( window.JQMIGRATE_WARN && Object.defineProperty ) {
    4242        // On ES5 browsers (non-oldIE), warn if the code tries to get prop;
    4343        // allow property to be overwritten in case some other plugin wants it
     
    6666}
    6767
    68 if ( JQMIGRATE_WARN && document.compatMode === "BackCompat" ) {
     68if ( window.JQMIGRATE_WARN && document.compatMode === "BackCompat" ) {
    6969    // jQuery has never supported or tested Quirks Mode
    7070    migrateWarn( "jQuery is not compatible with Quirks Mode" );
     
    8282
    8383// jQuery.attrFn
    84 if ( JQMIGRATE_WARN ) {
    85     migrateWarnProp( jQuery, "attrFn", attrFn, "jQuery.attrFn is deprecated" );
    86 }
     84migrateWarnProp( jQuery, "attrFn", attrFn, "jQuery.attrFn is deprecated" );
    8785
    8886jQuery.attr = function( elem, name, value, pass ) {
    8987    if ( pass ) {
    90         if ( JQMIGRATE_WARN ) {
    91             migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
    92         }
     88        migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
    9389        if ( elem && !rnoAttrNodeType.test( elem.nodeType ) && jQuery.isFunction( jQuery.fn[ name ] ) ) {
    9490            return jQuery( elem )[ name ]( value );
     
    9793
    9894    // Warn if user tries to set `type` since it breaks on IE 6/7/8
    99     if ( JQMIGRATE_WARN && name === "type" && value !== undefined && rnoType.test( elem.nodeName ) ) {
     95    if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) ) {
    10096        migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
    10197    }
     
    110106            return valueAttrGet.apply( this, arguments );
    111107        }
    112         if ( JQMIGRATE_WARN ) {
    113             migrateWarn("property-based jQuery.fn.attr('value') is deprecated");
    114         }
     108        migrateWarn("property-based jQuery.fn.attr('value') is deprecated");
    115109        return name in elem ?
    116110            elem.value :
     
    121115            return valueAttrSet.apply( this, arguments );
    122116        }
    123         if ( JQMIGRATE_WARN ) {
    124             migrateWarn("property-based jQuery.fn.attr('value', val) is deprecated");
    125         }
     117        migrateWarn("property-based jQuery.fn.attr('value', val) is deprecated");
    126118        // Does not return so that setAttribute is also used
    127119        elem.value = value;
     
    214206jQuery.browser = browser;
    215207
    216 if ( JQMIGRATE_WARN ) {
    217     // Warn if the code tries to get jQuery.browser
    218     migrateWarnProp( jQuery, "browser", browser, "jQuery.browser is deprecated" );
    219 }
     208// Warn if the code tries to get jQuery.browser
     209migrateWarnProp( jQuery, "browser", browser, "jQuery.browser is deprecated" );
    220210
    221211jQuery.sub = function() {
     
    237227    jQuerySub.fn.init.prototype = jQuerySub.fn;
    238228    var rootjQuerySub = jQuerySub(document);
    239     if ( JQMIGRATE_WARN ) {
    240         migrateWarn( "jQuery.sub() is deprecated" );
    241     }
     229    migrateWarn( "jQuery.sub() is deprecated" );
    242230    return jQuerySub;
    243231};
     
    255243        evt = jQuery._data( elem, name );
    256244        if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
    257             if ( JQMIGRATE_WARN ) {
    258                 migrateWarn("Use of jQuery.fn.data('events') is deprecated");
    259             }
     245            migrateWarn("Use of jQuery.fn.data('events') is deprecated");
    260246            return evt;
    261247        }
     
    297283    eventRemove = jQuery.event.remove,
    298284    eventTrigger = jQuery.event.trigger,
    299     oldToggle = jQuery.event.toggle,
     285    oldToggle = jQuery.fn.toggle,
    300286    oldLive = jQuery.fn.live,
    301287    oldDie = jQuery.fn.die,
     
    307293            return events;
    308294        }
    309         if ( JQMIGRATE_WARN && rhoverHack.test( events ) ) {
     295        if ( rhoverHack.test( events ) ) {
    310296            migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
    311297        }
     
    320306// Support for 'hover' pseudo-event and ajax event warnings
    321307jQuery.event.add = function( elem, types, handler, data, selector ){
    322     if ( JQMIGRATE_WARN && elem !== document && rajaxEvent.test( types ) ) {
     308    if ( elem !== document && rajaxEvent.test( types ) ) {
    323309        migrateWarn( "AJAX events should be attached to document: " + types );
    324310    }
     
    331317jQuery.fn.error = function( data, fn ) {
    332318    var args = Array.prototype.slice.call( arguments, 0);
    333     if ( JQMIGRATE_WARN ) {
    334         migrateWarn("jQuery.fn.error() is deprecated");
    335     }
     319    migrateWarn("jQuery.fn.error() is deprecated");
    336320    args.splice( 0, 0, "error" );
    337321    if ( arguments.length ) {
     
    349333        return oldToggle.apply( this, arguments );
    350334    }
    351     if ( JQMIGRATE_WARN ) {
    352         migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
    353     }
     335    migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
    354336
    355337    // Save reference to arguments for access in closure
     
    379361
    380362jQuery.fn.live = function( types, data, fn ) {
    381     if ( JQMIGRATE_WARN ) {
    382         migrateWarn("jQuery.fn.live() is deprecated");
    383     }
     363    migrateWarn("jQuery.fn.live() is deprecated");
    384364    if ( oldLive ) {
    385365        return oldLive.apply( this, arguments );
     
    390370
    391371jQuery.fn.die = function( types, fn ) {
    392     if ( JQMIGRATE_WARN ) {
    393         migrateWarn("jQuery.fn.die() is deprecated");
    394     }
     372    migrateWarn("jQuery.fn.die() is deprecated");
    395373    if ( oldDie ) {
    396374        return oldDie.apply( this, arguments );
     
    402380// Turn global events into document-triggered events
    403381jQuery.event.trigger = function( event, data, elem, onlyHandlers  ){
    404     if ( JQMIGRATE_WARN && !elem & !rajaxEvent.test( event ) ) {
     382    if ( !elem & !rajaxEvent.test( event ) ) {
    405383        migrateWarn( "Global events are undocumented and deprecated" );
    406384    }
Note: See TracChangeset for help on using the changeset viewer.