OLD | NEW |
(Empty) | |
| 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 |
| 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/mocks.dart' show ErrorRefMock; |
| 9 import 'package:observatory/service_html.dart' show ServiceMap, DartError; |
| 10 import 'package:observatory/src/elements/error_ref.dart'; |
| 11 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 12 import 'package:observatory/src/elements/shims/binding.dart'; |
| 13 |
| 14 class ErrorRefElementWrapper extends HtmlElement { |
| 15 |
| 16 static final binder = new Binder<ErrorRefElementWrapper>( |
| 17 const [const Binding('ref')]); |
| 18 |
| 19 static const tag = const Tag<ErrorRefElementWrapper>('error-ref'); |
| 20 |
| 21 ServiceMap _error; |
| 22 ServiceMap get ref => _error; |
| 23 void set ref(ServiceMap ref) { _error = ref; render(); } |
| 24 |
| 25 ErrorRefElementWrapper.created() : super.created() { |
| 26 binder.registerCallback(this); |
| 27 createShadowRoot(); |
| 28 render(); |
| 29 } |
| 30 |
| 31 @override |
| 32 void attached() { |
| 33 super.attached(); |
| 34 render(); |
| 35 } |
| 36 |
| 37 void render() { |
| 38 shadowRoot.children = []; |
| 39 if (_error == null) return; |
| 40 |
| 41 if (ref is Map) { |
| 42 shadowRoot.children = [ |
| 43 new StyleElement() |
| 44 ..text = '@import "packages/observatory/src/elements/css/shared.css";'
, |
| 45 new ErrorRefElement(new ErrorRefMock(message: ref['message'])) |
| 46 ]; |
| 47 } else { |
| 48 shadowRoot.children = [ |
| 49 new StyleElement() |
| 50 ..text = '@import "packages/observatory/src/elements/css/shared.css";'
, |
| 51 new ErrorRefElement( |
| 52 new ErrorRefMock(message: (ref as DartError).message), |
| 53 queue: ObservatoryApplication.app.queue) |
| 54 ]; |
| 55 } |
| 56 } |
| 57 } |
OLD | NEW |