JQuery Sizzle. find [Source Code Analysis]

Source: Internet
Author: User

JQuery Sizzle. find [Source Code Analysis]

Sizzle. find = function (expr, context, isXML) {var set, I, len, match, type, left; // whether expr is null if (! Expr) {return [];} for (I = 0, len = Expr. order. length; I <len; I ++) {type = Expr. order [I]; // according to Expr. order, that is, Sizzle. selectors. four types of order: ID, CLASS, NAME, TAG // determine the expr type with leftMatch if (match = Expr. leftMatch [type cmd.exe c (expr) {// left is officially used to determine whether the subsequent expressions are escaped, // The person thinks that the left here basically has no meaning left = match [1]; match. splice (1, 1); if (left. substr (left. length-1 )! = "\") {// Re-convert match [1], for example, \: escape :,\. convert. match [1] = (match [1] | ""). replace (rBackslash, ""); // call different find methods for different types and return the query results. The corresponding element set = Expr. find [type] (match, context, isXML); // if the query result is not empty, delete the query expression if (set! = Null) {expr = expr. replace (Expr. match [type], ""); break ;}}// if the result is null, search for if (! Set) {set = typeof context. getElementsByTagName! = "Undefined "? Context. getElementsByTagName ("*"): [] ;}// return the temporary result return {set: set, expr: expr };};

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.