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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tools/dom/templates/html/impl/impl_HTMLTemplateElement.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_HTMLTemplateElement.darttemplate b/tools/dom/templates/html/impl/impl_HTMLTemplateElement.darttemplate
new file mode 100644
index 0000000000000000000000000000000000000000..a8459d12bff2cfdb186098393f81b7e279e65ed7
--- /dev/null
+++ b/tools/dom/templates/html/impl/impl_HTMLTemplateElement.darttemplate
@@ -0,0 +1,119 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+part of $LIBRARYNAME;
+
+@Experimental
+$(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
+$!MEMBERS
+
+ // For real TemplateElement use the actual DOM .content field instead of
+ // our polyfilled expando.
+ @Experimental
+ DocumentFragment get content => $dom_content;
+
+ static StreamController<DocumentFragment> _instanceCreated;
+
+ /**
+ * *Warning*: This is an implementation helper for Model-Driven Views and
+ * should not be used in your code.
+ *
+ * This event is fired whenever a template is instantiated via
+ * [createInstance].
+ */
+ // TODO(rafaelw): This is a hack, and is neccesary for the polyfill
+ // because custom elements are not upgraded during clone()
+ @Experimental
+ static Stream<DocumentFragment> get instanceCreated {
+ if (_instanceCreated == null) {
+ _instanceCreated = new StreamController<DocumentFragment>();
+ }
+ return _instanceCreated.stream;
+ }
+
+ /**
+ * Ensures proper API and content model for template elements.
+ *
+ * [instanceRef] can be used to set the [Element.ref] property of [template],
+ * and use the ref's content will be used as source when createInstance() is
+ * invoked.
+ *
+ * Returns true if this template was just decorated, or false if it was
+ * already decorated.
+ */
+ @Experimental
+ static bool decorate(Element template, [Element instanceRef]) {
+ // == true check because it starts as a null field.
+ if (template._templateIsDecorated == true) return false;
+
+ template._templateIsDecorated = true;
+
+ _injectStylesheet();
+
+ // Create content
+ if (template is! TemplateElement) {
+ var doc = _getTemplateContentsOwner(template.document);
+ template._templateContent = doc.createDocumentFragment();
+ }
+
+ if (instanceRef != null) {
+ template._templateInstanceRef = instanceRef;
+ return true; // content is empty.
+ }
+
+ if (template is TemplateElement) {
+ _bootstrapTemplatesRecursivelyFrom(template.content);
+ } else {
+ _liftNonNativeTemplateChildrenIntoContent(template);
+ }
+
+ return true;
+ }
+
+ /**
+ * This used to decorate recursively all templates from a given node.
+ *
+ * By default [decorate] will be called on templates lazily when certain
+ * properties such as [model] are accessed, but it can be run eagerly to
+ * decorate an entire tree recursively.
+ */
+ // TODO(rafaelw): Review whether this is the right public API.
+ @Experimental
+ static void bootstrap(Node content) {
+ _bootstrapTemplatesRecursivelyFrom(content);
+ }
+
+ static bool _initStyles;
+
+ static void _injectStylesheet() {
+ if (_initStyles == true) return;
+ _initStyles = true;
+
+ var style = new StyleElement();
+ style.text = r'''
+template,
+thead[template],
+tbody[template],
+tfoot[template],
+th[template],
+tr[template],
+td[template],
+caption[template],
+colgroup[template],
+col[template],
+option[template] {
+ display: none;
+}''';
+ document.head.append(style);
+ }
+
+ /**
+ * A mapping of names to Custom Syntax objects. See [CustomBindingSyntax] for
+ * more information.
+ */
+ @Experimental
+ static Map<String, CustomBindingSyntax> syntax = {};
+}

Powered by Google App Engine
This is Rietveld 408576698