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

Side by Side Diff: tools/dom/templates/html/impl/impl_HTMLTemplateElement.darttemplate

Issue 14732003: Implement Model-Driven-Views spec for Dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: try upload again Created 7 years, 7 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // WARNING: Do not edit - generated code.
6
7 part of $LIBRARYNAME;
8
9 @Experimental
10 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
11 $!MEMBERS
12
13 // For real TemplateElement use the actual DOM .content field instead of
14 // our polyfilled expando.
15 @Experimental
16 DocumentFragment get content => $dom_content;
17
18 static StreamController<DocumentFragment> _instanceCreated;
19
20 /**
21 * *Warning*: This is an implementation helper for Model-Driven Views and
22 * should not be used in your code.
23 *
24 * This event is fired whenever a template is instantiated via
25 * [createInstance].
26 */
27 // TODO(rafaelw): This is a hack, and is neccesary for the polyfill
28 // because custom elements are not upgraded during clone()
29 @Experimental
30 static Stream<DocumentFragment> get instanceCreated {
31 if (_instanceCreated == null) {
32 _instanceCreated = new StreamController<DocumentFragment>();
33 }
34 return _instanceCreated.stream;
35 }
36
37 /**
38 * Ensures proper API and content model for template elements.
39 *
40 * [instanceRef] can be used to set the [Element.ref] property of [template],
41 * and use the ref's content will be used as source when createInstance() is
42 * invoked.
43 *
44 * Returns true if this template was just decorated, or false if it was
45 * already decorated.
46 */
47 @Experimental
48 static bool decorate(Element template, [Element instanceRef]) {
49 // == true check because it starts as a null field.
50 if (template._templateIsDecorated == true) return false;
51
52 template._templateIsDecorated = true;
53
54 _injectStylesheet();
55
56 // Create content
57 if (template is! TemplateElement) {
58 var doc = _getTemplateContentsOwner(template.document);
59 template._templateContent = doc.createDocumentFragment();
60 }
61
62 if (instanceRef != null) {
63 template._templateInstanceRef = instanceRef;
64 return true; // content is empty.
65 }
66
67 if (template is TemplateElement) {
68 _bootstrapTemplatesRecursivelyFrom(template.content);
69 } else {
70 _liftNonNativeTemplateChildrenIntoContent(template);
71 }
72
73 return true;
74 }
75
76 /**
77 * This used to decorate recursively all templates from a given node.
78 *
79 * By default [decorate] will be called on templates lazily when certain
80 * properties such as [model] are accessed, but it can be run eagerly to
81 * decorate an entire tree recursively.
82 */
83 // TODO(rafaelw): Review whether this is the right public API.
84 @Experimental
85 static void bootstrap(Node content) {
86 _bootstrapTemplatesRecursivelyFrom(content);
87 }
88
89 static bool _initStyles;
90
91 static void _injectStylesheet() {
92 if (_initStyles == true) return;
93 _initStyles = true;
94
95 var style = new StyleElement();
96 style.text = r'''
97 template,
98 thead[template],
99 tbody[template],
100 tfoot[template],
101 th[template],
102 tr[template],
103 td[template],
104 caption[template],
105 colgroup[template],
106 col[template],
107 option[template] {
108 display: none;
109 }''';
110 document.head.append(style);
111 }
112
113 /**
114 * A mapping of names to Custom Syntax objects. See [CustomBindingSyntax] for
115 * more information.
116 */
117 @Experimental
118 static Map<String, CustomBindingSyntax> syntax = {};
119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698