| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of mdv; | 5 part of mdv; |
| 6 | 6 |
| 7 /** Extensions to the [Element] API. */ | 7 /** Extensions to the [Element] API. */ |
| 8 class _ElementExtension extends _NodeExtension { | 8 class _ElementExtension extends _NodeExtension { |
| 9 _ElementExtension(Element node) : super(node); | 9 _ElementExtension(Element node) : super(node); |
| 10 | 10 |
| 11 // TODO(jmesserly): should path be optional, and default to empty path? | 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 | 12 // It is used that way in at least one path in JS TemplateElement tests |
| 13 // (see "BindImperative" test in original JS code). | 13 // (see "BindImperative" test in original JS code). |
| 14 NodeBinding createBinding(String name, model, String path) => | 14 NodeBinding createBinding(String name, model, String path) => |
| 15 new _AttributeBinding(node, name, model, 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.'); |
| 16 } | 20 } |
| 17 | 21 |
| 18 class _AttributeBinding extends NodeBinding { | 22 class _AttributeBinding extends NodeBinding { |
| 19 final bool conditional; | 23 final bool conditional; |
| 20 | 24 |
| 21 _AttributeBinding._(node, name, model, path, this.conditional) | 25 _AttributeBinding._(node, name, model, path, this.conditional) |
| 22 : super(node, name, model, path); | 26 : super(node, name, model, path); |
| 23 | 27 |
| 24 factory _AttributeBinding(Element node, name, model, path) { | 28 factory _AttributeBinding(Element node, name, model, path) { |
| 25 bool conditional = name.endsWith('?'); | 29 bool conditional = name.endsWith('?'); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 39 } else { | 43 } else { |
| 40 node.xtag.attributes.remove(property); | 44 node.xtag.attributes.remove(property); |
| 41 } | 45 } |
| 42 } else { | 46 } else { |
| 43 // TODO(jmesserly): escape value if needed to protect against XSS. | 47 // TODO(jmesserly): escape value if needed to protect against XSS. |
| 44 // See https://github.com/polymer-project/mdv/issues/58 | 48 // See https://github.com/polymer-project/mdv/issues/58 |
| 45 node.xtag.attributes[property] = sanitizeBoundValue(value); | 49 node.xtag.attributes[property] = sanitizeBoundValue(value); |
| 46 } | 50 } |
| 47 } | 51 } |
| 48 } | 52 } |
| OLD | NEW |