OLD | NEW |
| (Empty) |
1 // Copyright (c) 2016, 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 | |
7 import 'package:observatory/app.dart'; | |
8 import 'package:observatory/src/elements/helpers/tag.dart'; | |
9 import 'package:observatory/src/elements/shims/binding.dart'; | |
10 import 'package:observatory/src/elements/nav/menu_item.dart'; | |
11 | |
12 @bindable | |
13 class NavMenuItemElementWrapper extends HtmlElement { | |
14 static const binder = const Binder<NavMenuItemElementWrapper>(const { | |
15 'anchor': #anchor, 'link': #link | |
16 }); | |
17 | |
18 static const tag = | |
19 const Tag<NavMenuItemElementWrapper>('nav-menu-item'); | |
20 | |
21 String _anchor; | |
22 String _link; | |
23 | |
24 String get anchor => _anchor; | |
25 String get link => _link; | |
26 | |
27 set anchor(String value) { | |
28 _anchor = value; | |
29 render(); | |
30 } | |
31 set link(String value) { | |
32 _link = value; | |
33 render(); | |
34 } | |
35 | |
36 NavMenuItemElementWrapper.created() : super.created() { | |
37 binder.registerCallback(this); | |
38 _anchor = getAttribute('anchor'); | |
39 _link = getAttribute('link'); | |
40 createShadowRoot(); | |
41 render(); | |
42 } | |
43 | |
44 @override | |
45 void attached() { | |
46 super.attached(); | |
47 render(); | |
48 } | |
49 | |
50 void render() { | |
51 shadowRoot.children = []; | |
52 if (_anchor == null) { | |
53 return; | |
54 } | |
55 | |
56 shadowRoot.children = [ | |
57 new NavMenuItemElement(_anchor, link: '#$link', | |
58 queue: ObservatoryApplication.app.queue) | |
59 ..children = [new ContentElement()] | |
60 ]; | |
61 } | |
62 } | |
OLD | NEW |