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 /** Common utility functions used by code generated by the dwc compiler. */ | 5 /** Common utility functions used by code generated by the dwc compiler. */ |
6 library templating; | 6 library templating; |
7 | 7 |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'dart:uri'; | 9 import 'dart:uri'; |
10 import 'package:web_ui/safe_html.dart'; | 10 import 'package:web_ui/safe_html.dart'; |
11 import 'package:web_ui/watcher.dart'; | 11 import 'package:web_ui/watcher.dart'; |
12 | 12 |
13 /** | 13 /** |
14 * Removes all sibling nodes from `start.nextNode` until [end] (inclusive). For | 14 * Removes all sibling nodes from `start.nextNode` until [end] (inclusive). For |
15 * convinience, this function returns [start]. | 15 * convinience, this function returns [start]. |
16 */ | 16 */ |
17 Node removeNodes(Node start, Node end) { | 17 Node removeNodes(Node start, Node end) { |
18 var parent = end != null ? end.parent : null; | 18 var parent = end != null ? end.parentNode : null; |
19 if (parent == null) return start; | 19 if (parent == null) return start; |
20 | 20 |
21 while (start != end) { | 21 while (start != end) { |
22 var prev = end.previousNode; | 22 var prev = end.previousNode; |
23 // TODO(sigmund): use `end.remove()` after dartbug.com/7173 is fixed | 23 // TODO(sigmund): use `end.remove()` after dartbug.com/7173 is fixed |
24 parent.$dom_removeChild(end); | 24 parent.$dom_removeChild(end); |
25 end = prev; | 25 end = prev; |
26 } | 26 } |
27 return start; | 27 return start; |
28 } | 28 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 return _SAFE_SCHEMES.contains(scheme.toLowerCase()) || | 213 return _SAFE_SCHEMES.contains(scheme.toLowerCase()) || |
214 "MAILTO" == scheme.toUpperCase(); | 214 "MAILTO" == scheme.toUpperCase(); |
215 } | 215 } |
216 | 216 |
217 /** An error thrown when data bindings are set up with incorrect data. */ | 217 /** An error thrown when data bindings are set up with incorrect data. */ |
218 class DataBindingError implements Error { | 218 class DataBindingError implements Error { |
219 final message; | 219 final message; |
220 DataBindingError(this.message); | 220 DataBindingError(this.message); |
221 toString() => "Data binding error: $message"; | 221 toString() => "Data binding error: $message"; |
222 } | 222 } |
OLD | NEW |