jquery-migrate.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**
  2. * Created by duhuan on 2017/9/14.
  3. */
  4. /*! jQuery Migrate v1.2.1 | (c) 2005, 2013 jQuery Foundation, Inc. and other contributors | jquery.org/license */
  5. jQuery.migrateMute === void 0 && (jQuery.migrateMute = !0), function (e, t, n) {
  6. function r(n) {
  7. var r = t.console;
  8. i[n] || (i[n] = !0, e.migrateWarnings.push(n), r && r.warn && !e.migrateMute && (r.warn("JQMIGRATE: " + n), e.migrateTrace && r.trace && r.trace()))
  9. }
  10. function a(t, a, i, o) {
  11. if (Object.defineProperty)try {
  12. return Object.defineProperty(t, a, {
  13. configurable: !0, enumerable: !0, get: function () {
  14. return r(o), i
  15. }, set: function (e) {
  16. r(o), i = e
  17. }
  18. }), n
  19. } catch (s) {
  20. }
  21. e._definePropertyBroken = !0, t[a] = i
  22. }
  23. var i = {};
  24. e.migrateWarnings = [], !e.migrateMute && t.console && t.console.log && t.console.log("JQMIGRATE: Logging is active"), e.migrateTrace === n && (e.migrateTrace = !0), e.migrateReset = function () {
  25. i = {}, e.migrateWarnings.length = 0
  26. }, "BackCompat" === document.compatMode && r("jQuery is not compatible with Quirks Mode");
  27. var o = e("<input/>", {size: 1}).attr("size") && e.attrFn, s = e.attr, u = e.attrHooks.value && e.attrHooks.value.get || function () {
  28. return null
  29. }, c = e.attrHooks.value && e.attrHooks.value.set || function () {
  30. return n
  31. }, l = /^(?:input|button)$/i, d = /^[238]$/, p = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, f = /^(?:checked|selected)$/i;
  32. a(e, "attrFn", o || {}, "jQuery.attrFn is deprecated"), e.attr = function (t, a, i, u) {
  33. var c = a.toLowerCase(), g = t && t.nodeType;
  34. return u && (4 > s.length && r("jQuery.fn.attr( props, pass ) is deprecated"), t && !d.test(g) && (o ? a in o : e.isFunction(e.fn[a]))) ? e(t)[a](i) : ("type" === a && i !== n && l.test(t.nodeName) && t.parentNode && r("Can't change the 'type' of an input or button in IE 6/7/8"), !e.attrHooks[c] && p.test(c) && (e.attrHooks[c] = {
  35. get: function (t, r) {
  36. var a, i = e.prop(t, r);
  37. return i === !0 || "boolean" != typeof i && (a = t.getAttributeNode(r)) && a.nodeValue !== !1 ? r.toLowerCase() : n
  38. }, set: function (t, n, r) {
  39. var a;
  40. return n === !1 ? e.removeAttr(t, r) : (a = e.propFix[r] || r, a in t && (t[a] = !0), t.setAttribute(r, r.toLowerCase())), r
  41. }
  42. }, f.test(c) && r("jQuery.fn.attr('" + c + "') may use property instead of attribute")), s.call(e, t, a, i))
  43. }, e.attrHooks.value = {
  44. get: function (e, t) {
  45. var n = (e.nodeName || "").toLowerCase();
  46. return "button" === n ? u.apply(this, arguments) : ("input" !== n && "option" !== n && r("jQuery.fn.attr('value') no longer gets properties"), t in e ? e.value : null)
  47. }, set: function (e, t) {
  48. var a = (e.nodeName || "").toLowerCase();
  49. return "button" === a ? c.apply(this, arguments) : ("input" !== a && "option" !== a && r("jQuery.fn.attr('value', val) no longer sets properties"), e.value = t, n)
  50. }
  51. };
  52. var g, h, v = e.fn.init, m = e.parseJSON, y = /^([^<]*)(<[\w\W]+>)([^>]*)$/;
  53. e.fn.init = function (t, n, a) {
  54. var i;
  55. return t && "string" == typeof t && !e.isPlainObject(n) && (i = y.exec(e.trim(t))) && i[0] && ("<" !== t.charAt(0) && r("$(html) HTML strings must start with '<' character"), i[3] && r("$(html) HTML text after last tag is ignored"), "#" === i[0].charAt(0) && (r("HTML string cannot start with a '#' character"), e.error("JQMIGRATE: Invalid selector string (XSS)")), n && n.context && (n = n.context), e.parseHTML) ? v.call(this, e.parseHTML(i[2], n, !0), n, a) : v.apply(this, arguments)
  56. }, e.fn.init.prototype = e.fn, e.parseJSON = function (e) {
  57. return e || null === e ? m.apply(this, arguments) : (r("jQuery.parseJSON requires a valid JSON string"), null)
  58. }, e.uaMatch = function (e) {
  59. e = e.toLowerCase();
  60. var t = /(chrome)[ \/]([\w.]+)/.exec(e) || /(webkit)[ \/]([\w.]+)/.exec(e) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e) || /(msie) ([\w.]+)/.exec(e) || 0 > e.indexOf("compatible") && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e) || [];
  61. return {browser: t[1] || "", version: t[2] || "0"}
  62. }, e.browser || (g = e.uaMatch(navigator.userAgent), h = {}, g.browser && (h[g.browser] = !0, h.version = g.version), h.chrome ? h.webkit = !0 : h.webkit && (h.safari = !0), e.browser = h), a(e, "browser", e.browser, "jQuery.browser is deprecated"), e.sub = function () {
  63. function t(e, n) {
  64. return new t.fn.init(e, n)
  65. }
  66. e.extend(!0, t, this), t.superclass = this, t.fn = t.prototype = this(), t.fn.constructor = t, t.sub = this.sub, t.fn.init = function (r, a) {
  67. return a && a instanceof e && !(a instanceof t) && (a = t(a)), e.fn.init.call(this, r, a, n)
  68. }, t.fn.init.prototype = t.fn;
  69. var n = t(document);
  70. return r("jQuery.sub() is deprecated"), t
  71. }, e.ajaxSetup({converters: {"text json": e.parseJSON}});
  72. var b = e.fn.data;
  73. e.fn.data = function (t) {
  74. var a, i, o = this[0];
  75. return !o || "events" !== t || 1 !== arguments.length || (a = e.data(o, t), i = e._data(o, t), a !== n && a !== i || i === n) ? b.apply(this, arguments) : (r("Use of jQuery.fn.data('events') is deprecated"), i)
  76. };
  77. var j = /\/(java|ecma)script/i, w = e.fn.andSelf || e.fn.addBack;
  78. e.fn.andSelf = function () {
  79. return r("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()"), w.apply(this, arguments)
  80. }, e.clean || (e.clean = function (t, a, i, o) {
  81. a = a || document, a = !a.nodeType && a[0] || a, a = a.ownerDocument || a, r("jQuery.clean() is deprecated");
  82. var s, u, c, l, d = [];
  83. if (e.merge(d, e.buildFragment(t, a).childNodes), i)for (c = function (e) {
  84. return !e.type || j.test(e.type) ? o ? o.push(e.parentNode ? e.parentNode.removeChild(e) : e) : i.appendChild(e) : n
  85. }, s = 0; null != (u = d[s]); s++)e.nodeName(u, "script") && c(u) || (i.appendChild(u), u.getElementsByTagName !== n && (l = e.grep(e.merge([], u.getElementsByTagName("script")), c), d.splice.apply(d, [s + 1, 0].concat(l)), s += l.length));
  86. return d
  87. });
  88. var Q = e.event.add, x = e.event.remove, k = e.event.trigger, N = e.fn.toggle, T = e.fn.live, M = e.fn.die, S = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess", C = RegExp("\\b(?:" + S + ")\\b"), H = /(?:^|\s)hover(\.\S+|)\b/, A = function (t) {
  89. return "string" != typeof t || e.event.special.hover ? t : (H.test(t) && r("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'"), t && t.replace(H, "mouseenter$1 mouseleave$1"))
  90. };
  91. e.event.props && "attrChange" !== e.event.props[0] && e.event.props.unshift("attrChange", "attrName", "relatedNode", "srcElement"), e.event.dispatch && a(e.event, "handle", e.event.dispatch, "jQuery.event.handle is undocumented and deprecated"), e.event.add = function (e, t, n, a, i) {
  92. e !== document && C.test(t) && r("AJAX events should be attached to document: " + t), Q.call(this, e, A(t || ""), n, a, i)
  93. }, e.event.remove = function (e, t, n, r, a) {
  94. x.call(this, e, A(t) || "", n, r, a)
  95. }, e.fn.error = function () {
  96. var e = Array.prototype.slice.call(arguments, 0);
  97. return r("jQuery.fn.error() is deprecated"), e.splice(0, 0, "error"), arguments.length ? this.bind.apply(this, e) : (this.triggerHandler.apply(this, e), this)
  98. }, e.fn.toggle = function (t, n) {
  99. if (!e.isFunction(t) || !e.isFunction(n))return N.apply(this, arguments);
  100. r("jQuery.fn.toggle(handler, handler...) is deprecated");
  101. var a = arguments, i = t.guid || e.guid++, o = 0, s = function (n) {
  102. var r = (e._data(this, "lastToggle" + t.guid) || 0) % o;
  103. return e._data(this, "lastToggle" + t.guid, r + 1), n.preventDefault(), a[r].apply(this, arguments) || !1
  104. };
  105. for (s.guid = i; a.length > o;)a[o++].guid = i;
  106. return this.click(s)
  107. }, e.fn.live = function (t, n, a) {
  108. return r("jQuery.fn.live() is deprecated"), T ? T.apply(this, arguments) : (e(this.context).on(t, this.selector, n, a), this)
  109. }, e.fn.die = function (t, n) {
  110. return r("jQuery.fn.die() is deprecated"), M ? M.apply(this, arguments) : (e(this.context).off(t, this.selector || "**", n), this)
  111. }, e.event.trigger = function (e, t, n, a) {
  112. return n || C.test(e) || r("Global events are undocumented and deprecated"), k.call(this, e, t, n || document, a)
  113. }, e.each(S.split("|"), function (t, n) {
  114. e.event.special[n] = {
  115. setup: function () {
  116. var t = this;
  117. return t !== document && (e.event.add(document, n + "." + e.guid, function () {
  118. e.event.trigger(n, null, t, !0)
  119. }), e._data(this, n, e.guid++)), !1
  120. }, teardown: function () {
  121. return this !== document && e.event.remove(document, n + "." + e._data(this, n)), !1
  122. }
  123. }
  124. })
  125. }(jQuery, window);