| 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 html; | 5 part of html; |
| 6 | 6 |
| 7 /// @domName $DOMNAME | 7 /// @domName $DOMNAME |
| 8 /** | 8 /** |
| 9 * The base class for all documents. | 9 * The base class for all documents. |
| 10 * | 10 * |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 * var items = document.queryAll('.itemClassName'); | 55 * var items = document.queryAll('.itemClassName'); |
| 56 * | 56 * |
| 57 * For details about CSS selector syntax, see the | 57 * For details about CSS selector syntax, see the |
| 58 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | 58 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). |
| 59 */ | 59 */ |
| 60 List<Element> queryAll(String selectors) { | 60 List<Element> queryAll(String selectors) { |
| 61 if (new RegExp("""^\\[name=["'][^'"]+['"]\\]\$""").hasMatch(selectors)) { | 61 if (new RegExp("""^\\[name=["'][^'"]+['"]\\]\$""").hasMatch(selectors)) { |
| 62 final mutableMatches = $dom_getElementsByName( | 62 final mutableMatches = $dom_getElementsByName( |
| 63 selectors.substring(7,selectors.length - 2)); | 63 selectors.substring(7,selectors.length - 2)); |
| 64 int len = mutableMatches.length; | 64 int len = mutableMatches.length; |
| 65 final copyOfMatches = new List<Element>(len); | 65 final copyOfMatches = new List<Element>.fixedLength(len); |
| 66 for (int i = 0; i < len; ++i) { | 66 for (int i = 0; i < len; ++i) { |
| 67 copyOfMatches[i] = mutableMatches[i]; | 67 copyOfMatches[i] = mutableMatches[i]; |
| 68 } | 68 } |
| 69 return new _FrozenElementList._wrap(copyOfMatches); | 69 return new _FrozenElementList._wrap(copyOfMatches); |
| 70 } else if (new RegExp("^[*a-zA-Z0-9]+\$").hasMatch(selectors)) { | 70 } else if (new RegExp("^[*a-zA-Z0-9]+\$").hasMatch(selectors)) { |
| 71 final mutableMatches = $dom_getElementsByTagName(selectors); | 71 final mutableMatches = $dom_getElementsByTagName(selectors); |
| 72 int len = mutableMatches.length; | 72 int len = mutableMatches.length; |
| 73 final copyOfMatches = new List<Element>(len); | 73 final copyOfMatches = new List<Element>.fixedLength(len); |
| 74 for (int i = 0; i < len; ++i) { | 74 for (int i = 0; i < len; ++i) { |
| 75 copyOfMatches[i] = mutableMatches[i]; | 75 copyOfMatches[i] = mutableMatches[i]; |
| 76 } | 76 } |
| 77 return new _FrozenElementList._wrap(copyOfMatches); | 77 return new _FrozenElementList._wrap(copyOfMatches); |
| 78 } else { | 78 } else { |
| 79 return new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); | 79 return new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 } | 82 } |
| OLD | NEW |