Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(935)

Side by Side Diff: runtime/observatory/lib/src/elements/isolate_ref.dart

Issue 2119733003: Wrapping leaf nodes in non polymer elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixed CSS leak on firefox Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library isolate_ref_element; 5 library isolate_ref_element;
6 6
7 import 'package:polymer/polymer.dart'; 7 import 'dart:html';
8 import 'service_ref.dart'; 8 import 'dart:async';
9 import 'package:observatory/repositories.dart'
10 show IsolateRef, IsolateUpdateEvent;
11 import 'helpers/tag.dart';
9 12
10 @CustomTag('isolate-ref') 13 class IsolateRefElement extends HtmlElement {
11 class IsolateRefElement extends ServiceRefElement { 14 static final StyleElement _style = () {
12 IsolateRefElement.created() : super.created(); 15 var style = new StyleElement();
16 style.text = 'a.isolate-ref {'
17 ' color: #0489c3;'
18 ' text-decoration: none;'
19 '}'
20 'a.isolate-ref:hover {'
21 ' text-decoration: underline;'
22 '}';
23 return style;
24 }();
25
26 static const tag = const Tag<IsolateRefElement>('isolate-ref-wrapped');
27
28 Stream<IsolateUpdateEvent> _updates;
29 StreamSubscription _updatesSubscription;
30 IsolateRef _isolate;
31
32 IsolateRef get isolate => _isolate;
33
34 factory IsolateRefElement(IsolateRef isolate,
35 Stream<IsolateUpdateEvent> updates) {
36 assert(isolate != null);
37 assert(updates != null);
38 IsolateRefElement e = document.createElement(tag.name);
39 e._isolate = isolate;
40 e._updates = updates;
41 return e;
42 }
43
44 IsolateRefElement.created() : super.created() {
45 createShadowRoot();
46 }
47
48 @override
49 void attached() {
50 super.attached();
51 assert(_isolate != null);
52 assert(_updates != null);
53 render();
54 _updatesSubscription = _updates
55 .where((IsolateUpdateEvent e) => e.isolate.id == isolate.id)
56 .listen((IsolateUpdateEvent e) { _isolate = e.isolate; render(); });
57 }
58
59 @override
60 void detached() {
61 super.detached();
62 assert(_updatesSubscription != null);
63 _updatesSubscription.cancel();
64 _updatesSubscription = null;
65 }
66
67 void render() {
68 shadowRoot.children = [
69 _style.clone(true),
70 new AnchorElement(href:
71 '#/inspect?isolateId=${Uri.encodeComponent(isolate.id)}')
72 ..text = 'Isolate ${isolate.number} (${isolate.name})'
73 ..classes = ['isolate-ref']
74 ];
75 }
13 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698