| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library observatory_element; | 5 library observatory_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:observatory/app.dart'; | 9 import 'package:observatory/app.dart'; |
| 10 import 'package:observatory/service.dart'; | 10 import 'package:observatory/service.dart'; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 if (wasTruncated) { | 157 if (wasTruncated) { |
| 158 result.addAll("...".codeUnits); | 158 result.addAll("...".codeUnits); |
| 159 } else { | 159 } else { |
| 160 result.add("'".codeUnitAt(0)); | 160 result.add("'".codeUnitAt(0)); |
| 161 } | 161 } |
| 162 return new String.fromCharCodes(result); | 162 return new String.fromCharCodes(result); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void clearShadowRoot() { | 165 void clearShadowRoot() { |
| 166 // Remove all non-style elements. | 166 // Remove all non-style elements. |
| 167 shadowRoot.children.removeWhere((e) => e is! StyleElement); | 167 // Have to do the following because removeWhere doesn't work on DOM child |
| 168 // node lists. i.e. removeWhere((e) => e is! StyleElement); |
| 169 var styleElements = []; |
| 170 for (var child in shadowRoot.children) { |
| 171 if (child is StyleElement) { |
| 172 styleElements.add(child); |
| 173 } |
| 174 } |
| 175 shadowRoot.children.clear(); |
| 176 for (var style in styleElements) { |
| 177 shadowRoot.children.add(style); |
| 178 } |
| 168 } | 179 } |
| 169 | 180 |
| 170 void insertTextSpanIntoShadowRoot(String text) { | 181 void insertTextSpanIntoShadowRoot(String text) { |
| 171 var spanElement = new SpanElement(); | 182 var spanElement = new SpanElement(); |
| 172 spanElement.text = text; | 183 spanElement.text = text; |
| 173 shadowRoot.children.add(spanElement); | 184 shadowRoot.children.add(spanElement); |
| 174 } | 185 } |
| 175 | 186 |
| 176 void insertLinkIntoShadowRoot(String label, String href, [String title]) { | 187 void insertLinkIntoShadowRoot(String label, String href, [String title]) { |
| 177 var anchorElement = new AnchorElement(); | 188 var anchorElement = new AnchorElement(); |
| 178 anchorElement.href = href; | 189 anchorElement.href = href; |
| 179 anchorElement.text = label; | 190 anchorElement.text = label; |
| 180 if (title != null) { | 191 if (title != null) { |
| 181 anchorElement.title = title; | 192 anchorElement.title = title; |
| 182 } | 193 } |
| 183 anchorElement.onClick.listen(onClickGoto); | 194 anchorElement.onClick.listen(onClickGoto); |
| 184 shadowRoot.children.add(anchorElement); | 195 shadowRoot.children.add(anchorElement); |
| 185 } | 196 } |
| 186 } | 197 } |
| OLD | NEW |