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

Unified Diff: lib/polymer_element.dart

Issue 22417004: [pkg:polymer] add support for bool/int/double/String attributes (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: Created 7 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/polymer_element.dart
diff --git a/lib/polymer_element.dart b/lib/polymer_element.dart
index ec6f3694aa16a777625542e6b504dbdf2e770a15..e504eaaa8e6c132c3d7b4fcf6444fbb136ac9474 100644
--- a/lib/polymer_element.dart
+++ b/lib/polymer_element.dart
@@ -117,11 +117,24 @@ class PolymerElement extends CustomElement with _EventsMixin {
}
void created() {
- // TODO(jmesserly): this breaks until we get some kind of type conversion.
- // _publishedAttrs.forEach((name, propObserver) {
- // var value = attributes[name];
- // if (value != null) propObserver.value = value;
- // });
+ _publishedAttrs.forEach((name, propObserver) {
+ var oldValue = propObserver.value;
+ if (oldValue is bool) {
+ propObserver.value = attributes.containsKey(name);
+ return;
+ }
+ var value = attributes[name];
+ if (value == null) return;
+
+ if (oldValue is int) {
+ propObserver.value = int.parse(value, onError: (x) => null);
Siggi Cherem (dart-lang) 2013/08/06 16:40:39 should we assign onError or just skip setting the
Jennifer Messerly 2013/08/06 16:44:23 good question. I figured setting to "null" would s
Jennifer Messerly 2013/08/06 20:04:52 hmm, Polymer source code is not helpful in this ca
+ } else if (oldValue is double) {
+ propObserver.value = double.parse(value, (x) => null);
+ } else {
+ // Assume it's a string.
+ propObserver.value = value;
Siggi Cherem (dart-lang) 2013/08/06 16:40:39 how about: propObserver.value = value.toString();
Jennifer Messerly 2013/08/06 16:44:23 value will always be a string because it comes fro
Siggi Cherem (dart-lang) 2013/08/06 16:46:01 Ah, <facepalm>, makes sense. thx
+ }
+ });
_initShadowRoot();
_addHostListeners();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698