OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
6 | 6 |
7 /** | 7 /** |
8 * The base class for all documents. | 8 * The base class for all documents. |
9 * | 9 * |
10 * Each web page loaded in the browser has its own [Document] object, which is | 10 * Each web page loaded in the browser has its own [Document] object, which is |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 * var items = document.queryAll('.itemClassName'); | 54 * var items = document.queryAll('.itemClassName'); |
55 * | 55 * |
56 * For details about CSS selector syntax, see the | 56 * For details about CSS selector syntax, see the |
57 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | 57 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). |
58 */ | 58 */ |
59 List<Element> queryAll(String selectors) { | 59 List<Element> queryAll(String selectors) { |
60 if (new RegExp("""^\\[name=["'][^'"]+['"]\\]\$""").hasMatch(selectors)) { | 60 if (new RegExp("""^\\[name=["'][^'"]+['"]\\]\$""").hasMatch(selectors)) { |
61 final mutableMatches = $dom_getElementsByName( | 61 final mutableMatches = $dom_getElementsByName( |
62 selectors.substring(7,selectors.length - 2)); | 62 selectors.substring(7,selectors.length - 2)); |
63 int len = mutableMatches.length; | 63 int len = mutableMatches.length; |
64 final copyOfMatches = new List<Element>.fixedLength(len); | 64 final copyOfMatches = new List<Element>(len); |
65 for (int i = 0; i < len; ++i) { | 65 for (int i = 0; i < len; ++i) { |
66 copyOfMatches[i] = mutableMatches[i]; | 66 copyOfMatches[i] = mutableMatches[i]; |
67 } | 67 } |
68 return new _FrozenElementList._wrap(copyOfMatches); | 68 return new _FrozenElementList._wrap(copyOfMatches); |
69 } else if (new RegExp("^[*a-zA-Z0-9]+\$").hasMatch(selectors)) { | 69 } else if (new RegExp("^[*a-zA-Z0-9]+\$").hasMatch(selectors)) { |
70 final mutableMatches = $dom_getElementsByTagName(selectors); | 70 final mutableMatches = $dom_getElementsByTagName(selectors); |
71 int len = mutableMatches.length; | 71 int len = mutableMatches.length; |
72 final copyOfMatches = new List<Element>.fixedLength(len); | 72 final copyOfMatches = new List<Element>(len); |
73 for (int i = 0; i < len; ++i) { | 73 for (int i = 0; i < len; ++i) { |
74 copyOfMatches[i] = mutableMatches[i]; | 74 copyOfMatches[i] = mutableMatches[i]; |
75 } | 75 } |
76 return new _FrozenElementList._wrap(copyOfMatches); | 76 return new _FrozenElementList._wrap(copyOfMatches); |
77 } else { | 77 } else { |
78 return new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); | 78 return new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); |
79 } | 79 } |
80 } | 80 } |
81 } | 81 } |
OLD | NEW |