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

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: trying 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 /**
14 * True if `<template>` element is natively supported.
15 *
16 * Note: this primarily affects the HTML parser. Most other features of
17 * `<template>` work regardless of whether the parser supports template.
18 * You can workaround the lack of parser support by using the "template"
19 * attribute on certain nodes, see [isTemplate] for more information.
20 *
21 * See also: [content], [decorate], [bind], [unbind], [unbindAll].
22 */
23 static bool get supported => new Element.tag('template') is! UnknownElement;
blois 2013/05/01 17:00:42 Can use Element.isTagSupported instead. Also, can
Jennifer Messerly 2013/05/02 02:58:33 Done. Anywhere I can put the doc comment? I didn'
24
25 static StreamController<DocumentFragment> _instanceCreated;
26
27 /**
28 * *Warning*: This is an implementation helper for Model-Driven Views and
29 * should not be used in your code.
30 *
31 * This event is fired whenever a template is instantiated via
32 * [createInstance].
33 */
34 // TODO(rafaelw): This is a hack, and is neccesary for the polyfill
35 // because custom elements are not upgraded during clone()
36 @Experimental
37 static Stream<DocumentFragment> get instanceCreated {
blois 2013/05/01 17:00:42 Does this need to be public?
Jennifer Messerly 2013/05/01 17:56:34 yup! for same reason as MDV has it.
38 if (_instanceCreated == null) {
39 _instanceCreated = new StreamController<DocumentFragment>();
40 }
41 return _instanceCreated.stream;
42 }
43
44 /**
45 * Ensures proper API and content model for template elements.
46 *
47 * [instanceRef] can be used to set the [Element.ref] property of [template],
48 * and use the ref's content will be used as source when createInstance() is
49 * invoked.
50 *
51 * Returns true if this template was just decorated, or false if it was
52 * already decorated.
53 */
54 @Experimental
55 static bool decorate(Element template, [Element instanceRef]) {
56 // == true check because it starts as a null field.
57 if (template._templateIsDecorated == true) return false;
58
59 template._templateIsDecorated = true;
60
61 _injectStylesheet();
62
63 // Create content
64 if (template is! TemplateElement) {
65 var doc = _getTemplateContentsOwner(template.document);
66 template._templateContent = doc.createDocumentFragment();
67 }
68
69 if (instanceRef != null) {
70 template._templateInstanceRef = instanceRef;
71 return true; // content is empty.
72 }
73
74 if (template is TemplateElement) {
75 _bootstrapTemplatesRecursivelyFrom(template.content);
76 } else {
77 _liftNonNativeTemplateChildrenIntoContent(template);
78 }
79
80 return true;
81 }
82
83 /**
84 * This used to decorate recursively all templates from a given node.
85 *
86 * By default [decorate] will be called on templates lazily when certain
87 * properties such as [model] are accessed, but it can be run eagerly to
88 * decorate an entire tree recursively.
89 */
90 // TODO(rafaelw): Review whether this is the right public API.
91 @Experimental
92 static void bootstrap(Node content) {
93 _bootstrapTemplatesRecursivelyFrom(content);
94 }
95
96 static bool _initStyles;
97
98 static void _injectStylesheet() {
99 if (_initStyles == true) return;
100 _initStyles = true;
101
102 var style = new StyleElement();
103 style.text = r'''
104 template,
105 thead[template],
106 tbody[template],
107 tfoot[template],
108 th[template],
109 tr[template],
110 td[template],
111 caption[template],
112 colgroup[template],
113 col[template],
114 option[template] {
115 display: none;
116 }''';
117 document.head.nodes.add(style);
blois 2013/05/01 17:00:42 document.head.append(style) (it's faster).
Jennifer Messerly 2013/05/01 17:56:34 omg, I didn't know about .append! I'll fix that ev
118 }
119
120 /**
121 * A mapping of names to Custom Syntax objects. See [CustomBindingSyntax] for
122 * more information.
123 */
124 @Experimental
125 static Map<String, CustomBindingSyntax> syntax = {};
126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698