Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1208)

Side by Side Diff: lib/dom/templates/html/impl/impl_Document.darttemplate

Issue 10913125: Remove lib/dom directory! (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 class $CLASSNAME extends _NodeImpl implements Document
6 $if DART2JS
7 native "*HTMLDocument"
8 $endif
9 {
10
11 $!MEMBERS
12 // TODO(jacobr): implement all Element methods not on Document.
13
14 _ElementImpl query(String selectors) {
15 // It is fine for our RegExp to detect element id query selectors to have
16 // false negatives but not false positives.
17 if (const RegExp("^#[_a-zA-Z]\\w*\$").hasMatch(selectors)) {
18 return $dom_getElementById(selectors.substring(1));
19 }
20 return $dom_querySelector(selectors);
21 }
22
23 List<Element> queryAll(String selectors) {
24 if (const RegExp("""^\\[name=["'][^'"]+['"]\\]\$""").hasMatch(selectors)) {
25 final mutableMatches = $dom_getElementsByName(
26 selectors.substring(7,selectors.length - 2));
27 int len = mutableMatches.length;
28 final copyOfMatches = new List<Element>(len);
29 for (int i = 0; i < len; ++i) {
30 copyOfMatches[i] = mutableMatches[i];
31 }
32 return new _FrozenElementList._wrap(copyOfMatches);
33 } else if (const RegExp("^[*a-zA-Z0-9]+\$").hasMatch(selectors)) {
34 final mutableMatches = $dom_getElementsByTagName(selectors);
35 int len = mutableMatches.length;
36 final copyOfMatches = new List<Element>(len);
37 for (int i = 0; i < len; ++i) {
38 copyOfMatches[i] = mutableMatches[i];
39 }
40 return new _FrozenElementList._wrap(copyOfMatches);
41 } else {
42 return new _FrozenElementList._wrap($dom_querySelectorAll(selectors));
43 }
44 }
45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698