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/repositories.dart' show ScriptRepository; |
| 10 import 'package:observatory/service_html.dart' show SourceLocation; |
| 11 import 'package:observatory/src/elements/source_link.dart'; |
| 12 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 13 import 'package:observatory/src/elements/shims/binding.dart'; |
| 14 |
| 15 class SourceLinkElementWrapper extends HtmlElement { |
| 16 static final binder = new Binder<SourceLinkElementWrapper>( |
| 17 const [const Binding('location')]); |
| 18 |
| 19 static const tag = const Tag<SourceLinkElementWrapper>('source-link'); |
| 20 |
| 21 SourceLocation _location; |
| 22 SourceLocation get location => location; |
| 23 set location(SourceLocation location) { _location = location; render(); } |
| 24 |
| 25 SourceLinkElementWrapper.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 (_location == null) return; |
| 40 |
| 41 ScriptRepository repository = new ScriptRepository(_location.isolate); |
| 42 |
| 43 shadowRoot.children = [ |
| 44 new StyleElement() |
| 45 ..text = '@import "packages/observatory/src/elements/css/shared.css";', |
| 46 new SourceLinkElement(_location.isolate, _location, repository, |
| 47 queue: ObservatoryApplication.app.queue) |
| 48 ]; |
| 49 } |
| 50 } |
OLD | NEW |