Index: recipes/web/html/selectors_attribute.html |
diff --git a/recipes/web/html/selectors_attribute.html b/recipes/web/html/selectors_attribute.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..45972f7c1c204f597d52512704c1c26364f65859 |
--- /dev/null |
+++ b/recipes/web/html/selectors_attribute.html |
@@ -0,0 +1,62 @@ |
+<!DOCTYPE html> |
+ |
+<html> |
+ <head> |
+ <title>selectors_attribute</title> |
+ </head> |
+ |
+ <body> |
+ <p> |
+ <a href="example.html" hreflang="en">Some text</a><br> |
+ <a href="example.html" hreflang="en-UK">Some other text</a><br> |
+ <a href="example.html" hreflang="english">will not be outlined</a><br> |
+ </p> |
+ |
+ <script type="application/dart"> |
+ |
+ import 'dart:html'; |
+ |
+ List<Element> elements; |
+ void main() { |
+ |
+ // Match starts with string, or until '-'. |
+ List<Element> elements = queryAll(r'a[hreflang |= "en"]'); |
+ assert(elements.length == 2); |
+ |
+ // Match contains string. |
+ elements = queryAll(r'a[hreflang *= "en"]'); |
+ assert(elements.length == 3); |
+ |
+ // Whole word match. |
+ elements = queryAll(r'a[hreflang ~= "en"]'); |
+ assert(elements.length == 1); |
+ |
+ // Match ends with string. Won't work without a raw string or \$. |
+ elements = queryAll(r'a[hreflang $= "ish"]'); |
+ assert(elements.length == 1); |
+ |
+ // Match begins with string. |
+ elements = queryAll('a[hreflang ^= "en"]'); |
+ assert(elements.length == 3); |
+ |
+ // Exact match. |
+ elements = queryAll(r'a[hreflang = "english"]'); |
+ assert(elements.length == 1); |
+ |
+ // Exact negative match. Cannot use !=. |
+ elements = queryAll(r'a:not([hreflang = "english"])'); |
+ assert(elements.length == 2); |
+ |
+ // Has attribute. |
+ elements = queryAll('a[hreflang]'); |
+ assert(elements.length == 3); |
+ |
+ // Has multiple attributes. |
+ elements = queryAll('a[hreflang][href]'); |
+ assert(elements.length == 3); |
+ } |
+ |
+ </script> |
+ <script src="packages/browser/dart.js"></script> |
+ </body> |
+</html> |