/*!
* jQuery Migrate - v3.4.0 - 2022-03-24T16:30Z
* Copyright OpenJS Foundation and other contributors
*/
( function( factory ) {
"use strict";
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [ "jquery" ], function( jQuery ) {
return factory( jQuery, window );
} );
} else if ( typeof module === "object" && module.exports ) {
// Node/CommonJS
// eslint-disable-next-line no-undef
module.exports = factory( require( "jquery" ), window );
} else {
// Browser globals
factory( jQuery, window );
}
} )( function( jQuery, window ) {
"use strict";
jQuery.migrateVersion = "3.4.0";
// Returns 0 if v1 == v2, -1 if v1 < v2, 1 if v1 > v2
function compareVersions( v1, v2 ) {
var i,
rVersionParts = /^(\d+)\.(\d+)\.(\d+)/,
v1p = rVersionParts.exec( v1 ) || [ ],
v2p = rVersionParts.exec( v2 ) || [ ];
for ( i = 1; i <= 3; i++ ) {
if ( +v1p[ i ] > +v2p[ i ] ) {
return 1;
}
if ( +v1p[ i ] < +v2p[ i ] ) {
return -1;
}
}
return 0;
}
function jQueryVersionSince( version ) {
return compareVersions( jQuery.fn.jquery, version ) >= 0;
}
// A map from disabled patch codes to `true`. This should really
// be a `Set` but those are unsupported in IE.
var disabledPatches = Object.create( null );
// Don't apply patches for specified codes. Helpful for code bases
// where some Migrate warnings have been addressed and it's desirable
// to avoid needless patches or false positives.
jQuery.migrateDisablePatches = function() {
var i;
for ( i = 0; i < arguments.length; i++ ) {
disabledPatches[ arguments[ i ] ] = true;
}
};
// Allow enabling patches disabled via `jQuery.migrateDisablePatches`.
// Helpful if you want to disable a patch only for some code that won't
// be updated soon to be able to focus on other warnings - and enable it
// immediately after such a call:
// ```js
// jQuery.migrateDisablePatches( "workaroundA" );
// elem.pluginViolatingWarningA( "pluginMethod" );
// jQuery.migrateEnablePatches( "workaroundA" );
// ```
jQuery.migrateEnablePatches = function() {
var i;
for ( i = 0; i < arguments.length; i++ ) {
delete disabledPatches[ arguments[ i ] ];
}
};
jQuery.migrateIsPatchEnabled = function( patchCode ) {
return !disabledPatches[ patchCode ];
};
( function() {
// Support: IE9 only
// IE9 only creates console object when dev tools are first opened
// IE9 console is a host object, callable but doesn't have .apply()
if ( !window.console || !window.console.log ) {
return;
}
// Need jQuery 3.0.0+ and no older Migrate loaded
if ( !jQuery || !jQueryVersionSince( "3.0.0" ) ) {
window.console.log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" );
}
if ( jQuery.migrateWarnings ) {
window.console.log( "JQMIGRATE: Migrate plugin loaded multiple times" );
}
// Show a message on the console so devs know we're active
window.console.log( "JQMIGRATE: Migrate is installed" +
( jQuery.migrateMute ? "" : " with logging active" ) +
", version " + jQuery.migrateVersion );
} )();
var warnedAbout = {};
// By default each warning is only reported once.
jQuery.migrateDeduplicateWarnings = true;
// List of warnings already given; public read only
jQuery.migrateWarnings = [];
// Set to false to disable traces that appear with warnings
if ( jQuery.migrateTrace === undefined ) {
jQuery.migrateTrace = true;
}
// Forget any warnings we've already given; public
jQuery.migrateReset = function() {
warnedAbout = {};
jQuery.migrateWarnings.length = 0;
};
function migrateWarn( code, msg ) {
var console = window.console;
if ( jQuery.migrateIsPatchEnabled( code ) &&
( !jQuery.migrateDeduplicateWarnings || !warnedAbout[ msg ] ) ) {
warnedAbout[ msg ] = true;
jQuery.migrateWarnings.push( msg + " [" + code + "]" );
if ( console && console.warn && !jQuery.migrateMute ) {
console.warn( "JQMIGRATE: " + msg );
if ( jQuery.migrateTrace && console.trace ) {
console.trace();
}
}
}
}
function migrateWarnProp( obj, prop, value, code, msg ) {
Object.defineProperty( obj, prop, {
configurable: true,
enumerable: true,
get: function() {
migrateWarn( code, msg );
return value;
},
set: function( newValue ) {
migrateWarn( code, msg );
value = newValue;
}
} );
}
function migrateWarnFuncInternal( obj, prop, newFunc, code, msg ) {
var finalFunc,
origFunc = obj[ prop ];
obj[ prop ] = function() {
// If `msg` not provided, do not warn; more sophisticated warnings
// logic is most likely embedded in `newFunc`, in that case here
// we just care about the logic choosing the proper implementation
// based on whether the patch is disabled or not.
if ( msg ) {
migrateWarn( code, msg );
}
// Since patches can be disabled & enabled dynamically, we
// need to decide which implementation to run on each invocation.
finalFunc = jQuery.migrateIsPatchEnabled( code ) ?
newFunc :
// The function may not have existed originally so we need a fallback.
( origFunc || jQuery.noop );
return finalFunc.apply( this, arguments );
};
}
function migratePatchAndWarnFunc( obj, prop, newFunc, code, msg ) {
if ( !msg ) {
throw new Error( "No warning message provided" );
}
return migrateWarnFuncInternal( obj, prop, newFunc, code, msg );
}
function migratePatchFunc( obj, prop, newFunc, code ) {
return migrateWarnFuncInternal( obj, prop, newFunc, code );
}
if ( window.document.compatMode === "BackCompat" ) {
// jQuery has never supported or tested Quirks Mode
migrateWarn( "quirks", "jQuery is not compatible with Quirks Mode" );
}
var findProp,
class2type = {},
oldInit = jQuery.fn.init,
oldFind = jQuery.find,
rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g,
// Support: Android <=4.0 only
// Make sure we trim BOM and NBSP
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
migratePatchFunc( jQuery.fn, "init", function( arg1 ) {
var args = Array.prototype.slice.call( arguments );
if ( jQuery.migrateIsPatchEnabled( "selector-empty-id" ) &&
typeof arg1 === "string" && arg1 === "#" ) {
// JQuery( "#" ) is a bogus ID selector, but it returned an empty set
// before jQuery 3.0
migrateWarn( "selector-empty-id", "jQuery( '#' ) is not a valid selector" );
args[ 0 ] = [];
}
return oldInit.apply( this, args );
}, "selector-empty-id" );
// This is already done in Core but the above patch will lose this assignment
// so we need to redo it. It doesn't matter whether the patch is enabled or not
// as the method is always going to be a Migrate-created wrapper.
jQuery.fn.init.prototype = jQuery.fn;
migratePatchFunc( 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 {
window.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 {
window.document.querySelector( selector );
migrateWarn( "selector-hash",
"Attribute selector with '#' must be quoted: " + args[ 0 ] );
args[ 0 ] = selector;
} catch ( err2 ) {
migrateWarn( "selector-hash",
"Attribute selector with '#' was not fixed: " + args[ 0 ] );
}
}
}
return oldFind.apply( this, args );
}, "selector-hash" );
// Copy properties attached to original jQuery.find metho
没有合适的资源?快使用搜索试试~ 我知道了~
jquery-migrate
共4个文件
js:4个
1 下载量 24 浏览量
2023-03-05
00:33:55
上传
评论
收藏 26KB ZIP 举报
温馨提示
jQuery 迁移插件, Migrate 有两个版本。jquery-migrate-1.4.1版本将帮助您将 1.9 之前的 jQuery 代码更新到 jQuery 1.9 到 3.0。 jquery-migrate-3.4.0版本将帮助您更新代码以在 jQuery 3.0 或更高版本上运行。 jQuery Migrate是应用迁移辅助插件,是用于高级版本兼容低级版本辅助插件。 例如jQuery版本用的是1.x,计划升级到3.x,就可以在页面删除1.x版本,换成3.x版本,如果有脚本错误,就引入jquery-migrate插件用于兼容低版本,同时也显示低版本方法替换成新版本方法的方案。 jQuery migrate(转移、过度) jquery 升级后新旧代码不兼容问题,此包就是解决此问题的。 就是把不支持的函数再写出来支持下。 jQuery 版本之间有区别。比如1.9版本对于 live(),die(),toggle(),sub(),$.browser 等等都已经不支持了。 在不改变你网站代码的同时,要使用 1.9 之后的版本,你需要使用 jQuery migrate(转移、过度)
资源推荐
资源详情
资源评论
收起资源包目录
jquery-migrate.zip (4个子文件)
jquery-migrate-3.4.0.min.js 13KB
jquery-migrate-1.4.1.min.js 10KB
jquery-migrate-1.4.1.js 23KB
jquery-migrate-3.4.0.js 30KB
共 4 条
- 1
资源评论
鸭梨山大。
- 粉丝: 3331
- 资源: 35
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- WS2-32.lib,在编译程序中可以链接使用
- 秒懂傅里叶变换matlab程序实现过程
- ZEND解密dezender12
- sony 索尼IMX334摄像头模组电路板AD版硬件PCB图(6层板).zip
- 基于flask和echarts融合交易策略的bitfinex可视化微服务.zip
- 包含了wvp-assist.tar wvp-talk.tar zlmediakit.tar .
- 3r4efgh53wgrf43tw
- 2024新版Java基础从入门到精通全套视频+资料下载
- Spring AI大模型视频教程+ChatGPT视频教程+OpenAI大模型视频教程(资料+视频教程)
- ABB工业机器人教程PDF版本
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功