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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 14812016: expose MDV addBindings (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 87f446b401ff5e1e03cd84c9bce7a736ff75cf3b..50f53ec0530337de9e22aed055f6f790602f3c3d 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -7646,7 +7646,7 @@ abstract class Element extends Node implements ElementTraversal native "Element"
} else {
changed = (value) {
// TODO(jmesserly): escape value if needed to protect against XSS.
- // See https://github.com/toolkitchen/mdv/issues/58
+ // See https://github.com/polymer-project/mdv/issues/58
self.xtag.attributes[name] = value == null ? '' : '$value';
};
}
@@ -19371,6 +19371,22 @@ class TemplateElement extends Element native "HTMLTemplateElement" {
_Bindings._bootstrapTemplatesRecursivelyFrom(content);
}
+ /**
+ * Binds all mustaches recursively starting from the [root] node.
+ *
+ * Note: this is not an official Model-Driven-Views API; it is intended to
+ * support binding the [ShadowRoot]'s content to a model.
+ */
+ // TODO(jmesserly): this is needed to avoid two <template> nodes when using
+ // bindings in a custom element's template. See also:
+ // https://github.com/polymer-project/polymer/blob/master/src/bindMDV.js#L68
+ // Called from:
+ // https://github.com/polymer-project/polymer/blob/master/src/register.js#L99
+ @Experimental
+ static void bindModel(Node root, model, [CustomBindingSyntax syntax]) {
+ _Bindings._addBindings(root, model, syntax);
+ }
+
static bool _initStyles;
static void _injectStylesheet() {
@@ -25979,7 +25995,7 @@ class Rect {
// This code is a port of Model-Driven-Views:
-// https://github.com/toolkitchen/mdv
+// https://github.com/polymer-project/mdv
// The code mostly comes from src/template_element.js
typedef void _ChangeHandler(value);
@@ -26011,7 +26027,7 @@ typedef void _ChangeHandler(value);
*
* TemplateElement.syntax['MySyntax'] = new MySyntax();
*
- * See <https://github.com/toolkitchen/mdv/blob/master/docs/syntax.md> for more
+ * 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
@@ -26333,7 +26349,7 @@ class _Bindings {
// apply for template data-binding. HTML attributes are true if they're
// present. However Dart only treats "true" as true. Since this is HTML we'll
// use something closer to the HTML rules: null (missing) and false are false,
- // everything else is true. See: https://github.com/toolkitchen/mdv/issues/59
+ // everything else is true. See: https://github.com/polymer-project/mdv/issues/59
static bool _toBoolean(value) => null != value && false != value;
static Node _createDeepCloneAndDecorateTemplates(Node node, String syntax) {
@@ -26467,6 +26483,9 @@ class _Bindings {
return;
}
+ // If this is a custom element, give the .xtag a change to bind.
+ node = _nodeOrCustom(node);
+
if (tokens.length == 1 && tokens[0].isBinding) {
_bindOrDelegate(node, name, model, tokens[0].value, syntax);
return;
@@ -26498,7 +26517,7 @@ class _Bindings {
return newValue.toString();
};
- _nodeOrCustom(node).bind(name, replacementBinding, 'value');
+ node.bind(name, replacementBinding, 'value');
}
static void _bindOrDelegate(node, name, model, String path,
@@ -26512,7 +26531,7 @@ class _Bindings {
}
}
- _nodeOrCustom(node).bind(name, model, path);
+ node.bind(name, model, path);
}
/**
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698