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

Unified Diff: pkg/polymer/lib/src/declaration.dart

Issue 420673002: Roll polymer packages to version 0.3.4 (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/polymer/lib/src/build/script_compactor.dart ('k') | pkg/polymer/lib/src/events.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/declaration.dart
diff --git a/pkg/polymer/lib/src/declaration.dart b/pkg/polymer/lib/src/declaration.dart
index 0ae6641dbb983bbbff3fc7b0e761b3965c5eeec9..a82017baada84e1a6cc3e2f8b08dcb4d10bac738 100644
--- a/pkg/polymer/lib/src/declaration.dart
+++ b/pkg/polymer/lib/src/declaration.dart
@@ -41,6 +41,9 @@ class PolymerDeclaration {
Map<PropertyPath, List<Symbol>> _observe;
+ /// Name and expression for each computed property.
+ Map<Symbol, String> _computed = {};
+
Map<String, Object> _instanceAttributes;
/// A set of properties that should be automatically reflected to attributes.
@@ -110,6 +113,7 @@ class PolymerDeclaration {
// desugar compound observer syntax, e.g. @ObserveProperty('a b c')
explodeObservers();
+ createPropertyAccessors();
// install mdv delegate on template
installBindingDelegate(fetchTemplate());
// install external stylesheets as if they are inline
@@ -210,7 +214,8 @@ class PolymerDeclaration {
// remove excess ws
attr = attr.trim();
- // do not override explicit entries
+ // if the user hasn't specified a value, we want to use the
+ // default, unless a superclass has already chosen one
if (attr == '') continue;
var property = smoke.nameToSymbol(attr);
@@ -448,6 +453,26 @@ class PolymerDeclaration {
});
return map;
}
+
+ void createPropertyAccessors() {
+ // Dart note: since we don't have a prototype in Dart, most of the work of
+ // createPolymerAccessors is done lazily on the first access of properties.
+ // Here we just extract the information from annotations and store it as
+ // properties on the declaration.
+ var options = const smoke.QueryOptions(includeInherited: true,
+ includeUpTo: HtmlElement, withAnnotations: const [ComputedProperty]);
+ var existing = {};
+ for (var decl in smoke.query(type, options)) {
+ var meta = decl.annotations.firstWhere((e) => e is ComputedProperty);
+ var name = decl.name;
+ var prev = existing[name];
+ // The definition of a child class takes priority.
+ if (prev == null || smoke.isSubclassOf(decl.type, prev.type)) {
+ _computed[name] = meta.expression;
+ existing[name] = decl;
+ }
+ }
+ }
}
/// maps tag names to prototypes
« no previous file with comments | « pkg/polymer/lib/src/build/script_compactor.dart ('k') | pkg/polymer/lib/src/events.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698