Index: runtime/observatory/lib/src/elements/curly_block.dart |
diff --git a/runtime/observatory/lib/src/elements/curly_block.dart b/runtime/observatory/lib/src/elements/curly_block.dart |
index 9eadd76e67e9c8e3312ae55041688a65e47d7cd7..54e0d3f685d9ec94b762bc4dfa8078f1353746d2 100644 |
--- a/runtime/observatory/lib/src/elements/curly_block.dart |
+++ b/runtime/observatory/lib/src/elements/curly_block.dart |
@@ -16,20 +16,7 @@ class CurlyBlockToggleEvent { |
} |
class CurlyBlockElement extends HtmlElement implements Renderable { |
- static final StyleElement _style = () { |
- var style = new StyleElement(); |
- style.text = '''span.curly-block { |
- color: #0489c3; |
- cursor: pointer; |
- } |
- span.curly-block.disabled { |
- color: white; |
- cursor: wait; |
- }'''; |
- return style; |
- }(); |
- |
- static const tag = const Tag<CurlyBlockElement>('curly-block-wrapped'); |
+ static const tag = const Tag<CurlyBlockElement>('curly-block'); |
RenderingScheduler<CurlyBlockElement> _r; |
@@ -40,14 +27,21 @@ class CurlyBlockElement extends HtmlElement implements Renderable { |
bool _expanded; |
bool _disabled; |
+ Iterable<Element> _content = const []; |
bool get expanded => _expanded; |
+ bool get disabled => _disabled; |
+ Iterable<Element> get content => _content; |
+ |
set expanded(bool value) { |
if (_expanded != value) _onToggle.add(new CurlyBlockToggleEvent(this)); |
_expanded = _r.checkAndReact(_expanded, value); |
} |
- bool get disabled => _disabled; |
set disabled(bool value) => _disabled = _r.checkAndReact(_disabled, value); |
+ set content(Iterable<Element> value) { |
+ _content = value.toList(); |
+ _r.dirty(); |
+ } |
factory CurlyBlockElement({bool expanded: false, bool disabled: false, |
RenderingQueue queue}) { |
@@ -57,10 +51,11 @@ class CurlyBlockElement extends HtmlElement implements Renderable { |
e._r = new RenderingScheduler(e, queue: queue); |
e._expanded = expanded; |
e._disabled = disabled; |
+ e._r.enable(); |
return e; |
} |
- CurlyBlockElement.created() : super.created() { createShadowRoot(); } |
+ CurlyBlockElement.created() : super.created(); |
@override |
void attached() { super.attached(); _r.enable(); } |
@@ -68,7 +63,7 @@ class CurlyBlockElement extends HtmlElement implements Renderable { |
@override |
void detached() { |
super.detached(); _r.disable(notify: true); |
- shadowRoot.children = []; |
+ children = []; |
} |
void toggle() { |
@@ -80,8 +75,7 @@ class CurlyBlockElement extends HtmlElement implements Renderable { |
} |
void render() { |
- List<Element> children = [ |
- _style.clone(true), |
+ List<Element> content = [ |
new SpanElement()..text = '{' |
]; |
SpanElement label = new SpanElement() |
@@ -89,19 +83,17 @@ class CurlyBlockElement extends HtmlElement implements Renderable { |
..innerHtml = expanded ? |
' ⊟ ' : ' ⊞ '; |
if (disabled) { |
- children.add(label); |
+ content.add(label); |
} else { |
- children.add(new AnchorElement() |
+ content.add(new AnchorElement() |
..onClick.listen((_) { toggle(); }) |
..children = [label]); |
} |
if (expanded) { |
- children.addAll([ |
- new BRElement(), |
- new ContentElement() |
- ]); |
+ content.add(new BRElement()); |
+ content.addAll(_content); |
} |
- children.add(new SpanElement()..text = '}'); |
- shadowRoot.children = children; |
+ content.add(new SpanElement()..text = '}'); |
+ children = content; |
} |
} |