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

Side by Side Diff: pkg/mdv/lib/src/element.dart

Issue 34453003: Rename mdv -> template_binding, remove experiemntal apis from dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
« no previous file with comments | « pkg/mdv/lib/mdv.dart ('k') | pkg/mdv/lib/src/input_bindings.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, 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 part of mdv;
6
7 /** Extensions to the [Element] API. */
8 class _ElementExtension extends _NodeExtension {
9 _ElementExtension(Element node) : super(node);
10
11 // TODO(jmesserly): should path be optional, and default to empty path?
12 // It is used that way in at least one path in JS TemplateElement tests
13 // (see "BindImperative" test in original JS code).
14 NodeBinding createBinding(String name, model, String path) =>
15 new _AttributeBinding(node, name, model, path);
16
17 // Normally we issue this error in Element._ensureTemplate, but we
18 // avoid calling that from the model getter, so issue the error here.
19 get model => throw new UnsupportedError('$node is not a template.');
20 }
21
22 class _AttributeBinding extends NodeBinding {
23 final bool conditional;
24
25 _AttributeBinding._(node, name, model, path, this.conditional)
26 : super(node, name, model, path);
27
28 factory _AttributeBinding(Element node, name, model, path) {
29 bool conditional = name.endsWith('?');
30 if (conditional) {
31 node.xtag.attributes.remove(name);
32 name = name.substring(0, name.length - 1);
33 }
34 return new _AttributeBinding._(node, name, model, path, conditional);
35 }
36
37 Element get node => super.node;
38
39 void boundValueChanged(value) {
40 if (conditional) {
41 if (_toBoolean(value)) {
42 node.xtag.attributes[property] = '';
43 } else {
44 node.xtag.attributes.remove(property);
45 }
46 } else {
47 // TODO(jmesserly): escape value if needed to protect against XSS.
48 // See https://github.com/polymer-project/mdv/issues/58
49 node.xtag.attributes[property] = sanitizeBoundValue(value);
50 }
51 }
52 }
OLDNEW
« no previous file with comments | « pkg/mdv/lib/mdv.dart ('k') | pkg/mdv/lib/src/input_bindings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698