OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 error_ref_element; | 5 library error_ref_element; |
6 | 6 |
7 import 'package:polymer/polymer.dart'; | 7 import 'dart:html'; |
8 import 'service_ref.dart'; | 8 import 'package:observatory/repositories.dart' |
| 9 show ErrorRef; |
| 10 import 'package:observatory/src/elements/helpers/tag.dart'; |
9 | 11 |
10 @CustomTag('error-ref') | 12 class ErrorRefElement extends HtmlElement { |
11 class ErrorRefElement extends ServiceRefElement { | 13 static const tag = const Tag<ErrorRefElement>('error-ref-wrapped'); |
| 14 |
| 15 ErrorRef _error; |
| 16 ErrorRef get error => _error; |
| 17 |
| 18 factory ErrorRefElement(ErrorRef error) { |
| 19 assert(error != null); |
| 20 ErrorRefElement e = document.createElement(tag.name); |
| 21 e._error = error; |
| 22 return e; |
| 23 } |
| 24 |
12 ErrorRefElement.created() : super.created(); | 25 ErrorRefElement.created() : super.created(); |
| 26 |
| 27 @override |
| 28 void attached() { |
| 29 super.attached(); |
| 30 assert(error != null); |
| 31 render(); |
| 32 } |
| 33 |
| 34 void render() { |
| 35 children = [ |
| 36 new PreElement()..text = error.message |
| 37 ]; |
| 38 } |
13 } | 39 } |
OLD | NEW |