JQuery 1.10.2 Source Analysis Learning 1

Source: Internet
Author: User

Forward a previous article on the general framework of jquery suggested reading first

Var
Readylist,
Rootjquery,
core_strundefined = typeof Undefined,
Location = Window.location,
Document = Window.document,
Docelem = Document.documentelement,
_jquery = Window.jquery,
_$ = window.$,
Class2type = {},
Core_deletedids = [],
Core_version = "1.10.2",
Core_concat = Core_deletedids.concat,
Core_push = Core_deletedids.push,
Core_slice = Core_deletedids.slice,
Core_indexof = Core_deletedids.indexof,
core_tostring = class2type.tostring,
Core_hasown = Class2type.hasownproperty,
Core_trim = Core_version.trim,
JQuery = function (selector, context) {
return new JQuery.fn.init (selector, context, rootjquery);
},
Core_pnum =/[+-]? (?:\ d*\.|) \d+ (?: [ee][+-]?\d+|) /.source,
Core_rnotwhite =/\s+/g,
RTrim =/^[\s\ufeff\xa0]+| [\s\ufeff\xa0]+$/g,
rquickexpr =/^ (?: \ s* (<[\w\W]+>) [^>]*|# ([\w-]*)] $/,
Rsingletag =/^< (\w+) \s*\/?> (?: <\/\1>|) $/,
Rvalidchars =/^[\],:{}\s]*$/,
Rvalidbraces =/(?: ^|:|,) (?: \ s*\[) +/g,
Rvalidescape =/\\ (?: ["\\\/bfnrt]|u[\da-fa-f]{4})/g,
Rvalidtokens =/"[^" \\\r\n]* "|true|false|null|-? (?:\ d+\.|) \d+ (?: [ee][+-]?\d+|) /g,
Rmsprefix =/^-ms-/,
Rdashalpha =/-([\da-z])/gi,
Fcamelcase = function (all, letter) {
return Letter.touppercase ();
},
Completed = function (event) {
if (Document.addeventlistener | | event.type = = = "Load" | | document.readystate = = = "complete") {
Detach ();
Jquery.ready ();
}
},
Detach = function () {
if (Document.addeventlistener) {
Document.removeeventlistener ("domcontentloaded", completed, false);
Window.removeeventlistener ("Load", completed, false);

} else {
Document.detachevent ("onReadyStateChange", completed);
Window.detachevent ("onload", completed);
}
};

The above defines a number of function variables and methods (this explanation does not know right)

And jquery is in an anonymous function, using VAR to avoid the use of global variables, the advantage is not to conflict with other libraries or plug-ins

But jquery still has a global variable that is $

which

JQuery = function (selector, context) {
return new JQuery.fn.init (selector, context, rootjquery);
},

The purpose of this code is to build jquery objects, in fact, we return with $ () is an instance of the JQuery.fn.init object,

According to the JS syntax we can see that the prototype of this object points to the prototype of jquery. This enables chained programming operations.

function (window, undefined), the advantage of undefined parameter is to avoid the undefined variable being polluted.

JQuery 1.10.2 Source Analysis Learning 1 (EXT)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.