| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import 'dart:html'; | |
| 6 import 'dart:async'; | |
| 7 | |
| 8 import 'package:observatory/app.dart'; | |
| 9 import 'package:observatory/service_html.dart' show Script; | |
| 10 import 'package:observatory/src/elements/script_ref.dart'; | |
| 11 import 'package:observatory/src/elements/helpers/tag.dart'; | |
| 12 import 'package:observatory/src/elements/shims/binding.dart'; | |
| 13 | |
| 14 @bindable | |
| 15 class ScriptRefElementWrapper extends HtmlElement { | |
| 16 static const binder = const Binder<ScriptRefElementWrapper>(const { | |
| 17 'ref': #ref | |
| 18 }); | |
| 19 | |
| 20 static const tag = const Tag<ScriptRefElementWrapper>('script-ref'); | |
| 21 | |
| 22 Script _script; | |
| 23 | |
| 24 Script get ref => _script; | |
| 25 | |
| 26 set ref(Script value) { | |
| 27 _script = value; | |
| 28 render(); | |
| 29 } | |
| 30 | |
| 31 ScriptRefElementWrapper.created() : super.created() { | |
| 32 binder.registerCallback(this); | |
| 33 createShadowRoot(); | |
| 34 render(); | |
| 35 } | |
| 36 | |
| 37 @override | |
| 38 void attached() { | |
| 39 super.attached(); | |
| 40 render(); | |
| 41 } | |
| 42 | |
| 43 Future render() async { | |
| 44 shadowRoot.children = []; | |
| 45 if (_script == null) { | |
| 46 return; | |
| 47 } | |
| 48 | |
| 49 shadowRoot.children = [ | |
| 50 new StyleElement() | |
| 51 ..text = ''' | |
| 52 script-ref-wrapped > a[href]:hover { | |
| 53 text-decoration: underline; | |
| 54 } | |
| 55 script-ref-wrapped > a[href] { | |
| 56 color: #0489c3; | |
| 57 text-decoration: none; | |
| 58 }''', | |
| 59 new ScriptRefElement(_script.isolate, _script, | |
| 60 queue: ObservatoryApplication.app.queue) | |
| 61 ]; | |
| 62 } | |
| 63 } | |
| OLD | NEW |