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

Side by Side Diff: lib/web_ui.dart

Issue 22280002: use custom_element pkg (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: Created 7 years, 4 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 * This library exports all of the commonly used functions and types for 6 * This library exports all of the commonly used functions and types for
7 * building UI's. It is equivalent to the following imports: 7 * building UI's. It is equivalent to the following imports:
8 * 8 *
9 * import 'package:web_ui/observe.dart'; 9 * import 'package:web_ui/observe.dart';
10 * import 'package:web_ui/safe_html.dart'; 10 * import 'package:web_ui/safe_html.dart';
11 * import 'package:web_ui/templating.dart'; 11 * import 'package:web_ui/templating.dart';
12 * import 'package:web_ui/watcher.dart'; 12 * import 'package:web_ui/watcher.dart';
13 * import 'package:web_ui/web_ui.dart' show WebComponent; 13 * import 'package:web_ui/web_ui.dart' show WebComponent;
14 * 14 *
15 * Note that the [WebComponent] base class is defined in this library. 15 * Note that the [WebComponent] base class is defined in this library.
16 * 16 *
17 * See this article for more information: 17 * See this article for more information:
18 * <http://www.dartlang.org/articles/dart-web-components/>. 18 * <http://www.dartlang.org/articles/dart-web-components/>.
19 */ 19 */
20 library web_ui; 20 library web_ui;
21 21
22 export 'observe.dart'; 22 export 'observe.dart';
23 export 'safe_html.dart'; 23 export 'safe_html.dart';
24 export 'templating.dart'; 24 export 'templating.dart';
25 export 'watcher.dart'; 25 export 'watcher.dart';
26 26
27 import 'dart:async'; 27 import 'dart:async';
28 import 'dart:html'; 28 import 'dart:html';
29 import 'dart:mirrors' show reflect; 29 import 'package:custom_element/custom_element.dart' show CustomElement;
30 import 'package:meta/meta.dart'; 30 import 'package:meta/meta.dart';
31 31
32 /** 32 /**
33 * The base class for all Dart web components. In addition to the [Element] 33 * The base class for all Dart web components. In addition to the [Element]
34 * interface, it also provides lifecycle methods: 34 * interface, it also provides lifecycle methods:
35 * - [created] 35 * - [created]
36 * - [inserted] 36 * - [inserted]
37 * - [attributeChanged] 37 * - [attributeChanged]
38 * - [removed] 38 * - [removed]
39 */ 39 */
40 abstract class WebComponent implements Element { 40 abstract class WebComponent extends CustomElement {
41 /** The web component element wrapped by this class. */ 41 /** The web component element wrapped by this class. */
42 Element _host; 42 Element _host;
43 List _shadowRoots; 43 List _shadowRoots;
44 44
45 /** 45 /**
46 * Shadow roots generated by dwc for each custom element, indexed by the 46 * Shadow roots generated by dwc for each custom element, indexed by the
47 * custom element tag name. 47 * custom element tag name.
48 */ 48 */
49 Map<String, dynamic> _generatedRoots = {}; 49 Map<String, dynamic> _generatedRoots = {};
50 50
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 302
303 /** Distribute the [nodes] in place of an existing [insertionPoint]. */ 303 /** Distribute the [nodes] in place of an existing [insertionPoint]. */
304 static void _distribute(Element insertionPoint, Iterable<Node> nodes) { 304 static void _distribute(Element insertionPoint, Iterable<Node> nodes) {
305 assert(_isInsertionPoint(insertionPoint)); 305 assert(_isInsertionPoint(insertionPoint));
306 insertionPoint.parent.insertAllBefore(nodes, insertionPoint); 306 insertionPoint.parent.insertAllBefore(nodes, insertionPoint);
307 insertionPoint.remove(); 307 insertionPoint.remove();
308 } 308 }
309 309
310 // TODO(jmesserly): rename "created" to "onCreated". 310 // TODO(jmesserly): rename "created" to "onCreated".
311 void onCreated() => created(); 311 void onCreated() => created();
312
313 /** The rest of the [Element] API is handled by [host]. */
314 dynamic noSuchMethod(Invocation m) => reflect(host).delegate(m);
315 } 312 }
316 313
317 /** 314 /**
318 * Maps CSS selectors (class and) to a mangled name and maps x-component name 315 * Maps CSS selectors (class and) to a mangled name and maps x-component name
319 * to [is='x-component']. 316 * to [is='x-component'].
320 */ 317 */
321 class ScopedCssMapper { 318 class ScopedCssMapper {
322 final Map<String, String> _mapping; 319 final Map<String, String> _mapping;
323 320
324 ScopedCssMapper(this._mapping); 321 ScopedCssMapper(this._mapping);
(...skipping 14 matching lines...) Expand all
339 } 336 }
340 337
341 /** 338 /**
342 * Set this to true to use native Shadow DOM if it is supported. 339 * Set this to true to use native Shadow DOM if it is supported.
343 * Note that this will change behavior of [WebComponent] APIs for tree 340 * Note that this will change behavior of [WebComponent] APIs for tree
344 * traversal. 341 * traversal.
345 */ 342 */
346 bool useShadowDom = false; 343 bool useShadowDom = false;
347 344
348 bool get _realShadowRoot => useShadowDom && ShadowRoot.supported; 345 bool get _realShadowRoot => useShadowDom && ShadowRoot.supported;
OLDNEW
« lib/observe/map.dart ('K') | « lib/observe/map.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698