| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2016, 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 import 'dart:html'; | |
| 6 | |
| 7 import 'package:observatory/app.dart'; | |
| 8 import 'package:observatory/service.dart'; | |
| 9 import 'package:observatory/src/elements/error_ref.dart'; | |
| 10 import 'package:observatory/src/elements/helpers/tag.dart'; | |
| 11 import 'package:observatory/src/elements/shims/binding.dart'; | |
| 12 | |
| 13 class ErrorRefElementWrapper extends HtmlElement { | |
| 14 | |
| 15 static const binder = const Binder<ErrorRefElementWrapper>(const { | |
| 16 'ref': #ref | |
| 17 }); | |
| 18 | |
| 19 static const tag = const Tag<ErrorRefElementWrapper>('error-ref'); | |
| 20 | |
| 21 DartError _error; | |
| 22 | |
| 23 DartError get ref => _error; | |
| 24 | |
| 25 void set ref(DartError value) { | |
| 26 _error = value; | |
| 27 render(); | |
| 28 } | |
| 29 | |
| 30 ErrorRefElementWrapper.created() : super.created() { | |
| 31 binder.registerCallback(this); | |
| 32 createShadowRoot(); | |
| 33 render(); | |
| 34 } | |
| 35 | |
| 36 @override | |
| 37 void attached() { | |
| 38 super.attached(); | |
| 39 render(); | |
| 40 } | |
| 41 | |
| 42 void render() { | |
| 43 shadowRoot.children = []; | |
| 44 if (_error == null) { | |
| 45 return; | |
| 46 } | |
| 47 | |
| 48 shadowRoot.children = [ | |
| 49 new StyleElement() | |
| 50 ..text = ''' | |
| 51 error-ref-wrapped > pre { | |
| 52 background-color: #f5f5f5; | |
| 53 border: 1px solid #ccc; | |
| 54 padding-left: 10px; | |
| 55 padding-right: 10px; | |
| 56 font-family: consolas, courier, monospace; | |
| 57 font-size: 1em; | |
| 58 line-height: 1.2em; | |
| 59 white-space: pre; | |
| 60 } | |
| 61 ''', | |
| 62 new ErrorRefElement(_error, queue: ObservatoryApplication.app.queue) | |
| 63 ]; | |
| 64 } | |
| 65 } | |
| OLD | NEW |