OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 |
| 3 <html> |
| 4 <head> |
| 5 <title>selectors_attribute</title> |
| 6 </head> |
| 7 |
| 8 <body> |
| 9 <p> |
| 10 <a href="example.html" hreflang="en">Some text</a><br> |
| 11 <a href="example.html" hreflang="en-UK">Some other text</a><br> |
| 12 <a href="example.html" hreflang="english">will not be outlined</a><br> |
| 13 </p> |
| 14 |
| 15 <script type="application/dart"> |
| 16 |
| 17 import 'dart:html'; |
| 18 |
| 19 List<Element> elements; |
| 20 void main() { |
| 21 |
| 22 // Match starts with string, or until '-'. |
| 23 List<Element> elements = queryAll(r'a[hreflang |= "en"]'); |
| 24 assert(elements.length == 2); |
| 25 |
| 26 // Match contains string. |
| 27 elements = queryAll(r'a[hreflang *= "en"]'); |
| 28 assert(elements.length == 3); |
| 29 |
| 30 // Whole word match. |
| 31 elements = queryAll(r'a[hreflang ~= "en"]'); |
| 32 assert(elements.length == 1); |
| 33 |
| 34 // Match ends with string. Won't work without a raw string or \$. |
| 35 elements = queryAll(r'a[hreflang $= "ish"]'); |
| 36 assert(elements.length == 1); |
| 37 |
| 38 // Match begins with string. |
| 39 elements = queryAll('a[hreflang ^= "en"]'); |
| 40 assert(elements.length == 3); |
| 41 |
| 42 // Exact match. |
| 43 elements = queryAll(r'a[hreflang = "english"]'); |
| 44 assert(elements.length == 1); |
| 45 |
| 46 // Exact negative match. Cannot use !=. |
| 47 elements = queryAll(r'a:not([hreflang = "english"])'); |
| 48 assert(elements.length == 2); |
| 49 |
| 50 // Has attribute. |
| 51 elements = queryAll('a[hreflang]'); |
| 52 assert(elements.length == 3); |
| 53 |
| 54 // Has multiple attributes. |
| 55 elements = queryAll('a[hreflang][href]'); |
| 56 assert(elements.length == 3); |
| 57 } |
| 58 |
| 59 </script> |
| 60 <script src="packages/browser/dart.js"></script> |
| 61 </body> |
| 62 </html> |
OLD | NEW |