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 class ScriptRefElementWrapper extends HtmlElement { |
| 15 |
| 16 static final binder = new Binder<ScriptRefElementWrapper>( |
| 17 const [const Binding('ref')]); |
| 18 |
| 19 static const tag = const Tag<ScriptRefElementWrapper>('script-ref'); |
| 20 |
| 21 Script _script; |
| 22 Script get ref => _script; |
| 23 set ref(Script script) { _script = script; render(); } |
| 24 |
| 25 ScriptRefElementWrapper.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 Future render() async { |
| 38 shadowRoot.children = []; |
| 39 if (_script == null) return; |
| 40 |
| 41 shadowRoot.children = [ |
| 42 new StyleElement() |
| 43 ..text = '@import "packages/observatory/src/elements/css/shared.css";', |
| 44 new ScriptRefElement(_script.isolate, _script, |
| 45 queue: ObservatoryApplication.app.queue) |
| 46 ]; |
| 47 } |
| 48 } |
OLD | NEW |