the selector only supports one context and avoids IE8 bugs.
If (! Flag_xml & Doc. queryselectorall) {// ff, opera, chrome, and Safari XML files also implement the queryselectorall interface, but cannot use VaR query = expr; // getelementsbytagname of IE, queryselectorall has a problem in searching the child of the object element. If (doc.doc umentmode ===8 & context. nodetype = 1 & context. nodename. tolowercase ()! = "Object") {var id = context. getattribute ("ID"), uid = context. uniqueid // when the context is an element section, the search result contains your own if (! ID) {context. setattribute ("ID", UID);} Try {return pushresult (context. queryselectorall ("#" + uid + "" + query), result, flag_multi);} catch (e) {} finally {If (ID = context. uniqueid) {context. removeattribute ("ID") ;}} else {If (/\! \=/. Test (query) // manually supports e [ATTR! = Val] query = query. Replace (/\ [\ s * (\ W +) \ s *! = \ S * (['"] *). *? \ 3) \ s * \]/g, ": Not ([$1 = $2])"); try {return pushresult (context. queryselectorall (query), result, flag_multi);} catch (e ){}}}
The improvement is as follows. Now we only need to avoid the object bug of IE.
If (! Flag_xml & Doc. queryselectorall) {// http://www.w3.org/TR/selectors/ node = context; // use a replacement so that the multi-context implementation does not rearrange the search var usecontains = false; If (contexts. length> 2 | doc.doc umentmode ===8 & context. nodetype = 1) {node = Doc; usecontains = true;} if(doc.doc umentmode! = 8 | node. nodename. tolowercase ()! = "Object") {try {nodes = pushresult (node. queryselectorall (expr), result, flag_multi); var ret = [] If (usecontains & nodes. length) {var Cn = contexts. length; for (I = 0, rI = 0; I
Another improvement is to add a class name to the context of the element node so that the search can be completed in one step. The disadvantage is that you must operate the class before and after.
If (! Flag_xml & Doc. queryselectorall) {var query = expr; If (contexts. length> 2 | doc.doc umentmode = 8 & context. nodetype = 1) {If (contexts. length> 2) Context = Doc; query = ". fix_icarus_sqa "+ query; // use the class name to make sure that the search range is for (I = 0; node = contexts [I ++];) {If (node. nodetype = 1) {node. classname = "fix_icarus_sqa" + node. classname ;}}if(doc.doc umentmode! = 8 | context. nodename. tolowercase ()! = "Object") {try {result = pushresult (context. queryselectorall (query), result, flag_multi); If (query. indexof (". fix_icarus_sqa ") = 0) {// If a class name is added to the context, go to the class name for (I = 0; node = contexts [I ++];) {If (node. nodetype = 1) {node. classname = node. classname. replace ("fix_icarus_sqa", "") ;}} return result;} catch (e ){}}}
However, it is much faster to call Dom. Contains by performing operations on classes.