In the W3C draft, the attribute selector [ATT ~ = Val] when it comes to a vertex, Val cannot be a blank character. Otherwise, false is returned for comparing the flag value (flag is the comparison result between Val and the actual value of the element), while I write the selector, this requirement is also effective for other operators.
</P> <p> <! Doctype HTML> <br/> <pead> <br/> <title> attribute selector </title> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "> <br/> <SCRIPT> <br/> window. onload = function () {<br/> console. log (document. queryselector ("# test1 [Title =''] "); <br/> console. log (document. queryselector ("# test1 [Title ~ = '']"); <Br/> console. log (document. queryselector ("# test1 [Title | =''] "); <br/> console. log (document. queryselector ("# test1 [Title ^ =''] "); <br/> console. log (document. queryselector ("# test1 [Title $ =''] "); <br/> console. log (document. queryselector ("# test1 [Title * =''] "); <br/> console. log ("============================================ ====== ") <br/> console. log (document. queryselector ("# Test2 [Title =''] "); <br/> Co Nsole. Log (document. queryselector ("# Test2 [Title ~ = '']"); <Br/> console. log (document. queryselector ("# Test2 [Title | =''] "); <br/> console. log (document. queryselector ("# Test2 [Title ^ =''] "); <br/> console. log (document. queryselector ("# Test2 [Title $ =''] "); <br/> console. log (document. queryselector ("# Test2 [Title * =''] "); </P> <p >}</P> <p> </SCRIPT> <br/> </pead> <br/> <body> <br/> <Div title = "" id = "test1"> </div> <br/> <Div Title = "AAA" id = "Test2"> </div> <br/> </body> <br/> </ptml> </P> <p>
RUN Code
<! Doctype HTML>
Log: [object htmldivelement] Log: NULL log: [object htmldivelement] Log: NULL log: ========================================================== === log: null log: NULL log
In other words, as long as Val is empty, in addition to = or | =, flag must be false, and for non-= ,! = Operator. If the obtained value is a blank character, flag must be false.
The code for the fifth generation selector Icarus is as follows:
For (I = 0, rI = 0, ELEM; ELEM = elems [I ++];) {If (! OP) {flag = Icarus. hasattribute (ELEM, name, flag_xml); // [title]} else if (val = "" & OP> 3) {flag = false} else {ATTR = Icarus. getattribute (ELEM, name, flag_xml); Switch (OP) {Case 1: // = all attribute values are equal to the given Value Flag = ATTR = val; break; Case 2: //! = Non-Standard. The property value is not equal to the given value. Flag = ATTR! = Val; break; Case 3: // | = the property value is divided into two parts by "-", and the given value is equal to one part, or all equal to the value flag = ATTR = Val | ATTR. substring (0, Val. length + 1) = Val + "-"; break; Case 4 ://~ = The attribute value is multiple words and the given value is one of them. Flag = ATTR! = "" & ("" + ATTR + ""). indexof (VAL)> = 0; break; Case 5: // ^ = the attribute value starts with the given value. Flag = ATTR! = "" & ATTR. indexof (VAL) = 0; break; Case 6: // $ = the attribute value ends with a given value. Flag = ATTR! = "" & ATTR. lastindexof (VAL) + val. Length = ATTR. length; break; Case 7: // * = the attribute value contains the given Value Flag = ATTR! = "" & ATTR. indexof (VAL)> = 0; break;} If (flag ^ flag_not) TMP [ri ++] = ELEM ;}