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

Unified Diff: lib/src/emitters.dart

Issue 11315020: Add attribute information table so we generate correct setters. (Closed) Base URL: https://github.com/dart-lang/dart-web-components.git@master
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/src/html5_utils.dart » ('j') | lib/src/html5_utils.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/emitters.dart
diff --git a/lib/src/emitters.dart b/lib/src/emitters.dart
index ae89740bc0788355dc457d4bc8818ef7ec5cc985..5ececc4d5ffc71fe4285c1dcf70c7419c04fe828 100644
--- a/lib/src/emitters.dart
+++ b/lib/src/emitters.dart
@@ -218,15 +218,21 @@ class DataBindingEmitter extends Emitter<ElementInfo> {
''');
}
} else {
- var val = attrInfo.boundValue;
- var stopperName = attrInfo.stopperNames[0];
+ // Note: it is important for correctness to use the DOM setter if it
+ // is available. Otherwise changes will not be applied. This is most
+ // easily observed with "InputElement.value", ".checked", etc.
var setter;
- // TODO(sigmund): use setters when they are available (issue #112)
- if (elem.tagName == 'input' && (name == 'value' || name == 'checked')) {
- setter = name;
+ var allowedTags = htmlAttributeTags[name];
Siggi Cherem (dart-lang) 2012/10/27 00:46:45 nit: maybe some alternative name? allowedTags ring
+ if (allowedTags == allHtmlElements ||
+ allowedTags != null && allowedTags.contains(elem.tagName)) {
+ var renamed = elementFieldRenames[name];
Siggi Cherem (dart-lang) 2012/10/27 00:46:45 elementFieldRenames => domToDartHtml?
+ setter = renamed != null ? renamed : name;
} else {
- setter = 'attributes["$name"]';
+ setter = 'attributes["$name"]';
}
+
+ var val = attrInfo.boundValue;
+ var stopperName = attrInfo.stopperNames[0];
context.insertedMethod.add('''
$stopperName = autogenerated.watchAndInvoke(() => $val, (e) {
$elemField.$setter = e.newValue;
« no previous file with comments | « no previous file | lib/src/html5_utils.dart » ('j') | lib/src/html5_utils.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698