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

Side by Side Diff: samples/webcomponents/shadow_polyfill.dart

Issue 10919146: Get rid of a lot of () for getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « samples/ui_lib/view/view.dart ('k') | tests/benchmark_smoke/benchmark_base.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Polyfill script for custom elements. To use this script, your app must 6 * Polyfill script for custom elements. To use this script, your app must
7 * create a CustomElementsManager with the appropriate lookup function before 7 * create a CustomElementsManager with the appropriate lookup function before
8 * doing any DOM queries or modifications. 8 * doing any DOM queries or modifications.
9 * Currently, all custom elements must be registered with the polyfill. To 9 * Currently, all custom elements must be registered with the polyfill. To
10 * register custom elements, provide the appropriate lookup function to your 10 * register custom elements, provide the appropriate lookup function to your
(...skipping 11 matching lines...) Expand all
22 22
23 #source('list_map.dart'); 23 #source('list_map.dart');
24 24
25 // typedefs 25 // typedefs
26 typedef WebComponent WebComponentFactory (ShadowRoot shadowRoot, Element elt); 26 typedef WebComponent WebComponentFactory (ShadowRoot shadowRoot, Element elt);
27 typedef WebComponentFactory RegistryLookupFunction(String tagName); 27 typedef WebComponentFactory RegistryLookupFunction(String tagName);
28 28
29 // Globals 29 // Globals
30 const int REQUEST_DONE = 4; 30 const int REQUEST_DONE = 4;
31 CustomElementsManager _manager; 31 CustomElementsManager _manager;
32 CustomElementsManager get manager() => _manager; 32 CustomElementsManager get manager => _manager;
33 33
34 void initializeComponents(RegistryLookupFunction lookup) { 34 void initializeComponents(RegistryLookupFunction lookup) {
35 _manager = new CustomElementsManager._internal(lookup); 35 _manager = new CustomElementsManager._internal(lookup);
36 manager._loadComponents(); 36 manager._loadComponents();
37 } 37 }
38 38
39 /** A Dart wrapper for a web component. */ 39 /** A Dart wrapper for a web component. */
40 abstract class WebComponent { 40 abstract class WebComponent {
41 /** The web component element wrapped by this class. */ 41 /** The web component element wrapped by this class. */
42 abstract Element get element(); 42 abstract Element get element;
43 43
44 /** Invoked when this component gets created. */ 44 /** Invoked when this component gets created. */
45 abstract void created(); 45 abstract void created();
46 46
47 /** Invoked when this component gets inserted in the DOM tree. */ 47 /** Invoked when this component gets inserted in the DOM tree. */
48 abstract void inserted(); 48 abstract void inserted();
49 49
50 /** Invoked when any attribute of the component is modified. */ 50 /** Invoked when any attribute of the component is modified. */
51 abstract void attributeChanged( 51 abstract void attributeChanged(
52 String name, String oldValue, String newValue); 52 String name, String oldValue, String newValue);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 226 }
227 } 227 }
228 228
229 bool _hasShadowRoot; 229 bool _hasShadowRoot;
230 230
231 /** 231 /**
232 * True if the browser supports the [ShadowRoot] element and it is enabled. 232 * True if the browser supports the [ShadowRoot] element and it is enabled.
233 * See the [Shadow DOM spec](http://www.w3.org/TR/shadow-dom/) for more 233 * See the [Shadow DOM spec](http://www.w3.org/TR/shadow-dom/) for more
234 * information about the ShadowRoot. 234 * information about the ShadowRoot.
235 */ 235 */
236 bool get hasShadowRoot() { 236 bool get hasShadowRoot {
237 if (_hasShadowRoot == null) { 237 if (_hasShadowRoot == null) {
238 try { 238 try {
239 // TODO(jmesserly): it'd be nice if we could check this without causing 239 // TODO(jmesserly): it'd be nice if we could check this without causing
240 // an exception to be thrown. 240 // an exception to be thrown.
241 new ShadowRoot(new DivElement()); 241 new ShadowRoot(new DivElement());
242 _hasShadowRoot = true; 242 _hasShadowRoot = true;
243 } catch (e) { 243 } catch (e) {
244 _hasShadowRoot = false; 244 _hasShadowRoot = false;
245 // Hide <template> elements. 245 // Hide <template> elements.
246 // TODO(jmesserly): This is a workaround because we don't distribute 246 // TODO(jmesserly): This is a workaround because we don't distribute
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } 338 }
339 }); 339 });
340 attributeObserver.observe(e, attributes: true, attributeOldValue: true); 340 attributeObserver.observe(e, attributes: true, attributeOldValue: true);
341 341
342 // Listen for all insertions and deletions on the DOM so that we can 342 // Listen for all insertions and deletions on the DOM so that we can
343 // catch custom elements being inserted and call the appropriate callbacks. 343 // catch custom elements being inserted and call the appropriate callbacks.
344 manager.initializeInsertedRemovedCallbacks(shadowRoot); 344 manager.initializeInsertedRemovedCallbacks(shadowRoot);
345 return newCustomElement; 345 return newCustomElement;
346 } 346 }
347 } 347 }
OLDNEW
« no previous file with comments | « samples/ui_lib/view/view.dart ('k') | tests/benchmark_smoke/benchmark_base.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698