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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library polymer.polymer_element; 5 library polymer.polymer_element;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:mirrors'; 9 import 'dart:mirrors';
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 name = name.trim(); 110 name = name.trim();
111 111
112 // TODO(jmesserly): PathObserver is overkill here; it helps avoid 112 // TODO(jmesserly): PathObserver is overkill here; it helps avoid
113 // "new Symbol" and other mirrors-related warnings. 113 // "new Symbol" and other mirrors-related warnings.
114 _publishedAttrs[name] = new PathObserver(this, toCamelCase(name)); 114 _publishedAttrs[name] = new PathObserver(this, toCamelCase(name));
115 } 115 }
116 } 116 }
117 } 117 }
118 118
119 void created() { 119 void created() {
120 // TODO(jmesserly): this breaks until we get some kind of type conversion. 120 _publishedAttrs.forEach((name, propObserver) {
121 // _publishedAttrs.forEach((name, propObserver) { 121 var oldValue = propObserver.value;
122 // var value = attributes[name]; 122 if (oldValue is bool) {
123 // if (value != null) propObserver.value = value; 123 propObserver.value = attributes.containsKey(name);
124 // }); 124 return;
125 }
126 var value = attributes[name];
127 if (value == null) return;
128
129 if (oldValue is int) {
130 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
131 } else if (oldValue is double) {
132 propObserver.value = double.parse(value, (x) => null);
133 } else {
134 // Assume it's a string.
135 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
136 }
137 });
125 _initShadowRoot(); 138 _initShadowRoot();
126 _addHostListeners(); 139 _addHostListeners();
127 } 140 }
128 141
129 /** 142 /**
130 * Creates the document fragment to use for each instance of the custom 143 * Creates the document fragment to use for each instance of the custom
131 * element, given the `<template>` node. By default this is equivalent to: 144 * element, given the `<template>` node. By default this is equivalent to:
132 * 145 *
133 * template.createInstance(this, fancySyntax); 146 * template.createInstance(this, fancySyntax);
134 * 147 *
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 'onKeyMessage': MediaElement.keyMessageEvent, 529 'onKeyMessage': MediaElement.keyMessageEvent,
517 'onNeedKey': MediaElement.needKeyEvent, 530 'onNeedKey': MediaElement.needKeyEvent,
518 'onWebGlContextLost': CanvasElement.webGlContextLostEvent, 531 'onWebGlContextLost': CanvasElement.webGlContextLostEvent,
519 'onWebGlContextRestored': CanvasElement.webGlContextRestoredEvent, 532 'onWebGlContextRestored': CanvasElement.webGlContextRestoredEvent,
520 'onPointerLockChange': Document.pointerLockChangeEvent, 533 'onPointerLockChange': Document.pointerLockChangeEvent,
521 'onPointerLockError': Document.pointerLockErrorEvent, 534 'onPointerLockError': Document.pointerLockErrorEvent,
522 'onReadyStateChange': Document.readyStateChangeEvent, 535 'onReadyStateChange': Document.readyStateChangeEvent,
523 'onSelectionChange': Document.selectionChangeEvent, 536 'onSelectionChange': Document.selectionChangeEvent,
524 'onSecurityPolicyViolation': Document.securityPolicyViolationEvent, 537 'onSecurityPolicyViolation': Document.securityPolicyViolationEvent,
525 }; 538 };
OLDNEW
« 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