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

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Issue 19663011: Custom Syntax's are now enabled via template.bindingDelegate = (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: restore @Experimental Created 7 years, 5 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:
Download patch
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index 4a510d06ddabc60eaa179e95919a59700529bedb..7af79d4341494dbd69b33c78adf59d7d3aa38117 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -8928,13 +8928,15 @@ abstract class Element extends Node implements ElementTraversal {
}
/**
- * Creates an instance of the template.
+ * Creates an instance of the template, using the provided model and binding
+ * delegate.
+ *
* This is only supported if [isTemplate] is true.
*/
@Experimental()
- DocumentFragment createInstance(model, String syntax) {
+ DocumentFragment createInstance(model, BindingDelegate delegate) {
_ensureTemplate();
- return TemplateElement.mdvPackage(this).createInstance(model, syntax);
+ return TemplateElement.mdvPackage(this).createInstance(model, delegate);
}
/**
@@ -8950,6 +8952,22 @@ abstract class Element extends Node implements ElementTraversal {
TemplateElement.mdvPackage(this).model = value;
}
+ /**
+ * The binding delegate which is inherited through the tree. It can be used
+ * to configure custom syntax for `{{bindings}}` inside this template.
+ *
+ * This is only supported if [isTemplate] is true.
+ */
+ @Experimental()
+ BindingDelegate get bindingDelegate =>
+ TemplateElement.mdvPackage(this).bindingDelegate;
+
+ @Experimental()
+ void set bindingDelegate(BindingDelegate value) {
+ _ensureTemplate();
+ TemplateElement.mdvPackage(this).bindingDelegate = value;
+ }
+
// TODO(jmesserly): const set would be better
static const _TABLE_TAGS = const {
'caption': null,
@@ -22802,7 +22820,6 @@ class TableSectionElement extends _HTMLElement {
// WARNING: Do not edit - generated code.
-
/**
* Model-Driven Views (MDV)'s native features enables a wide-range of use cases,
* but (by design) don't attempt to implement a wide array of specialized
@@ -22811,32 +22828,31 @@ class TableSectionElement extends _HTMLElement {
* Enabling these features in MDV is a matter of implementing and registering an
* MDV Custom Syntax. A Custom Syntax is an object which contains one or more
* delegation functions which implement specialized behavior. This object is
- * registered with MDV via [TemplateElement.syntax]:
+ * registered with MDV via [Element.bindingDelegate]:
*
*
* HTML:
- * <template bind syntax="MySyntax">
+ * <template bind>
* {{ What!Ever('crazy')->thing^^^I+Want(data) }}
* </template>
*
* Dart:
- * class MySyntax extends CustomBindingSyntax {
+ * class MySyntax extends BindingDelegate {
* getBinding(model, path, name, node) {
* // The magic happens here!
* }
* }
- *
* ...
- *
- * TemplateElement.syntax['MySyntax'] = new MySyntax();
+ * query('template').bindingDelegate = new MySyntax();
+ * query('template').model = new MyModel();
*
* See <https://github.com/polymer-project/mdv/blob/master/docs/syntax.md> for
* more information about Custom Syntax.
*/
-// TODO(jmesserly): if this is just one method, a function type would make it
-// more Dart-friendly.
-@Experimental()
-abstract class CustomBindingSyntax {
+// TODO(jmesserly): move this type to the MDV package? Two issues: we'd lose
+// type annotation on [Element.bindingDelegate], and "mdv" is normally imported
+// with a prefix.
+abstract class BindingDelegate {
/**
* This syntax method allows for a custom interpretation of the contents of
* mustaches (`{{` ... `}}`).
@@ -22885,7 +22901,6 @@ abstract class CustomBindingSyntax {
getInstanceModel(Element template, model) => model;
}
-
@Experimental()
@DomName('HTMLTemplateElement')
@SupportedBrowser(SupportedBrowser.CHROME)
@@ -23104,13 +23119,6 @@ option[template] {
}''';
document.head.append(style);
}
-
- /**
- * A mapping of names to Custom Syntax objects. See [CustomBindingSyntax] for
- * more information.
- */
- @Experimental()
- static Map<String, CustomBindingSyntax> syntax = {};
}
// 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
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698