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

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

Issue 2159273004: Added helper function to automatically dirty a RenderingScheduler on attribute change (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Added comments to new helper method 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) 2016, the Dart project authors. Please see the AUTHORS file 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 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 import 'dart:html'; 5 import 'dart:html';
6 import 'dart:async'; 6 import 'dart:async';
7 import 'package:observatory/src/elements/helpers/tag.dart'; 7 import 'package:observatory/src/elements/helpers/tag.dart';
8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
9 9
10 class NavMenuElement extends HtmlElement implements Renderable { 10 class NavMenuElement extends HtmlElement implements Renderable {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 RenderingScheduler _r; 49 RenderingScheduler _r;
50 50
51 Stream<RenderedEvent<NavMenuElement>> get onRendered => _r.onRendered; 51 Stream<RenderedEvent<NavMenuElement>> get onRendered => _r.onRendered;
52 52
53 String _label; 53 String _label;
54 String _link; 54 String _link;
55 bool _last; 55 bool _last;
56 String get label => _label; 56 String get label => _label;
57 String get link => _link; 57 String get link => _link;
58 bool get last => _last; 58 bool get last => _last;
59 set label(String value) { 59 set label(String value) => _label = _r.checkAndReact(_label, value);
60 if (_label != value) { 60 set link(String value) => _link = _r.checkAndReact(_link, value);
61 _label = value; 61 set last(bool value) => _last = _r.checkAndReact(_link, value);
62 _r.dirty();
63 } else {
64 _r.scheduleNotification();
65 }
66 }
67 set link(String value) {
68 if (_link != value) {
69 _link = value;
70 _r.dirty();
71 } else {
72 _r.scheduleNotification();
73 }
74 }
75 set last(bool value) {
76 if (_last != value) {
77 _last = value;
78 _r.dirty();
79 } else {
80 _r.scheduleNotification();
81 }
82 }
83
84 62
85 factory NavMenuElement(String label, {String link, bool last: false, 63 factory NavMenuElement(String label, {String link, bool last: false,
86 RenderingQueue queue}) { 64 RenderingQueue queue}) {
87 assert(label != null); 65 assert(label != null);
88 assert(last != null); 66 assert(last != null);
89 NavMenuElement e = document.createElement(tag.name); 67 NavMenuElement e = document.createElement(tag.name);
90 e._r = new RenderingScheduler(e, queue: queue); 68 e._r = new RenderingScheduler(e, queue: queue);
91 e._label = label; 69 e._label = label;
92 e._link = link; 70 e._link = link;
93 e._last = last; 71 e._last = last;
(...skipping 28 matching lines...) Expand all
122 if (!last) { 100 if (!last) {
123 children.add( 101 children.add(
124 new LIElement() 102 new LIElement()
125 ..classes = ['nav-menu_spacer'] 103 ..classes = ['nav-menu_spacer']
126 ..innerHtml = '&gt;' 104 ..innerHtml = '&gt;'
127 ); 105 );
128 } 106 }
129 shadowRoot.children = children; 107 shadowRoot.children = children;
130 } 108 }
131 } 109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698