Key steps for Sizzle (selector, context, results, seed)1, the context of the incoming context and the current document is consistent, inconsistent call setdocument () re-set the document for the case of frame.2, if context is empty fix context for document3,selector If it is not a string or the context is not an element or document directly returns an empty array.4, if the document is HTML and does not pass in the filtered result set seed, try the native method getElementById, getElementsByTagName, Getelementsbyclassname, Queryselectorall method Find Element5, other cases, call the Select (Selector, context, results, Seed) method to find the element
here to detail decomposition is the setdocument () method, it is very long, it mainly does the following things1, set the document for the current code run environment (this document is not the document, it is a normal variable that references the document in the current window).2, to deal with getElementById, getElementsByTagName, getelementsbyclassname different browser differences, for different viewers set expr.find[' ID ',expr.filter[' ID ']a unified approach to performance3, dealing with QSA's bizarre behavior4. Set the Sort method for document5, returns the current document