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

Side by Side Diff: lib/web_ui.dart

Issue 13592003: add support for template repeat (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: Created 7 years, 8 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 exposes the types in [observe], [safe_html], [templating], 6 * This library exposes the types in [observe], [safe_html], [templating],
7 * [watcher] and the [WebComponent] base class. See this article for more 7 * [watcher] and the [WebComponent] base class. See this article for more
8 * information about this library: 8 * information about this library:
9 * <http://www.dartlang.org/articles/dart-web-components/>. 9 * <http://www.dartlang.org/articles/dart-web-components/>.
10 */ 10 */
11 library web_ui; 11 library web_ui;
12 12
13 export 'observe.dart'; 13 export 'observe.dart';
14 export 'safe_html.dart'; 14 export 'safe_html.dart';
15 export 'templating.dart'; 15 export 'templating.dart';
16 export 'watcher.dart'; 16 export 'watcher.dart';
17 17
18 import 'dart:async'; 18 import 'dart:async';
19 import 'dart:html'; 19 import 'dart:html';
20 20
21 import 'package:meta/meta.dart'; 21 import 'package:meta/meta.dart';
22 22
23 // Imported for the doc comment 23 // Imported for the doc comment
24 import 'observe.dart' as observe; 24 import 'observe.dart' as observe;
25 import 'safe_html.dart' as safe_html; 25 import 'safe_html.dart' as safe_html;
26 import 'templating.dart' as templating; 26 import 'templating.dart' as templating;
27 import 'watcher.dart' as watcher; 27 import 'watcher.dart' as watcher;
28 28
29 final Map _elements = new Map<String, _CustomElementInfo>();
30
31 class _CustomElementInfo {
32 final Element _elementElement;
33 final DocumentFragment _template;
34 _CustomElementInfo(this._elementElement, this._template);
35 }
36
37 /**
38 * This API registers an `<element>` element with the runtime system, so script
39 * code can use [getElementDefinition] and [getElementTemplate].
40 *
41 * Note: normally you should not need to call this, it will be done
42 * automatically by web_ui as part of the polyfill for the
43 * [element HTML element](https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec /custom/index.html#the-element-element).
44 */
45 void registerElementDefinition(Element element, DocumentFragment template) {
46 var name = element.attributes['name'];
47 if (name == null) throw new ArgumentError('custom element must have a name.');
48 _elements[name] = new _CustomElementInfo(element, template);
Siggi Cherem (dart-lang) 2013/04/05 20:09:24 should we warn when there are conflicts on the nam
49 }
50
51 /**
52 * Gets the custom `<element>` corresponding to the given tag name.
53 * These are registered automatically, or explicitly by calling
54 * [registerElementDefinition].
55 *
56 * Note that the `<template>` node's contents are not accessible from the
57 * returned node, and should be accessed via [getElementTemplate].
58 */
59 Element getElementDefinition(String tagName) =>
60 _elements[tagName]._elementElement;
61
62 /**
63 * Gets the custom `<element>` template contents. Conceptually this is
64 * equivalent to:
65 *
66 * getElementDefinition(tagName).template.content;
67 *
68 * However it works on browsers that don't have native support for
69 * `<element>` and `<template>`.
70 */
71 DocumentFragment getElementTemplate(String tagName) =>
72 _elements[tagName]._template;
73
74
Siggi Cherem (dart-lang) 2013/04/05 20:09:24 looks like these changes below with a different ch
Jennifer Messerly 2013/04/05 20:34:36 Yes! good catch. :D
29 /** 75 /**
30 * The base class for all Dart web components. In addition to the [Element] 76 * The base class for all Dart web components. In addition to the [Element]
31 * interface, it also provides lifecycle methods: 77 * interface, it also provides lifecycle methods:
32 * - [created] 78 * - [created]
33 * - [inserted] 79 * - [inserted]
34 * - [attributeChanged] 80 * - [attributeChanged]
35 * - [removed] 81 * - [removed]
36 */ 82 */
37 abstract class WebComponent implements Element { 83 abstract class WebComponent implements Element {
38 /** The web component element wrapped by this class. */ 84 /** The web component element wrapped by this class. */
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 } 713 }
668 714
669 /** 715 /**
670 * Set this to true to use native Shadow DOM if it is supported. 716 * Set this to true to use native Shadow DOM if it is supported.
671 * Note that this will change behavior of [WebComponent] APIs for tree 717 * Note that this will change behavior of [WebComponent] APIs for tree
672 * traversal. 718 * traversal.
673 */ 719 */
674 bool useShadowDom = false; 720 bool useShadowDom = false;
675 721
676 bool get _realShadowRoot => useShadowDom && ShadowRoot.supported; 722 bool get _realShadowRoot => useShadowDom && ShadowRoot.supported;
OLDNEW
« lib/templating.dart ('K') | « lib/templating.dart ('k') | test/analyzer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698