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

Unified Diff: pkg/template_binding/lib/src/element.dart

Issue 355133002: switch Node.bind to interop (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/template_binding/CHANGELOG.md ('k') | pkg/template_binding/lib/src/input_bindings.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/template_binding/lib/src/element.dart
diff --git a/pkg/template_binding/lib/src/element.dart b/pkg/template_binding/lib/src/element.dart
deleted file mode 100644
index 6d82baaf4a2bd8aa3f6fda3051b131174a6ce637..0000000000000000000000000000000000000000
--- a/pkg/template_binding/lib/src/element.dart
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (c) 2013, 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.
-
-part of template_binding;
-
-/** Extensions to the [Element] API. */
-class _ElementExtension extends NodeBindExtension {
- _ElementExtension(Element node) : super._(node);
-
- bind(String name, value, {bool oneTime: false}) {
- Element node = _node;
-
- if (node is OptionElement && name == 'value') {
- // Note: because <option> can be a semantic template, <option> will be
- // a TemplateBindExtension sometimes. So we need to handle it here.
- node.attributes.remove(name);
-
- if (oneTime) return _updateOption(value);
- _open(value, _updateOption);
- } else {
- bool conditional = name.endsWith('?');
- if (conditional) {
- node.attributes.remove(name);
- name = name.substring(0, name.length - 1);
- }
-
- if (oneTime) return _updateAttribute(_node, name, conditional, value);
-
- _open(value, (x) => _updateAttribute(_node, name, conditional, x));
- }
- return _maybeUpdateBindings(name, value);
- }
-
- void _updateOption(newValue) {
- OptionElement node = _node;
- var oldValue = null;
- var selectBinding = null;
- var select = node.parentNode;
- if (select is SelectElement) {
- var bindings = nodeBind(select).bindings;
- if (bindings != null) {
- var valueBinding = bindings['value'];
- if (valueBinding is _InputBinding) {
- selectBinding = valueBinding;
- oldValue = select.value;
- }
- }
- }
-
- node.value = _sanitizeValue(newValue);
-
- if (selectBinding != null && select.value != oldValue) {
- selectBinding.value = select.value;
- }
- }
-}
-
-void _updateAttribute(Element node, String name, bool conditional, value) {
- if (conditional) {
- if (_toBoolean(value)) {
- node.attributes[name] = '';
- } else {
- node.attributes.remove(name);
- }
- } else {
- // TODO(jmesserly): escape value if needed to protect against XSS.
- // See https://github.com/polymer-project/mdv/issues/58
- node.attributes[name] = _sanitizeValue(value);
- }
-}
« no previous file with comments | « pkg/template_binding/CHANGELOG.md ('k') | pkg/template_binding/lib/src/input_bindings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698