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

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

Issue 79353003: [polymer.dart] fix *Changed observers inheriting (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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/pkg.status ('k') | pkg/polymer/lib/src/instance.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 024c872ef56ca8fdd3a975fe0ac4c96ef374349c..e50628c5076d183722bc2b3da10fc67e942581ba 100644
--- a/pkg/polymer/lib/src/declaration.dart
+++ b/pkg/polymer/lib/src/declaration.dart
@@ -267,12 +267,7 @@ class PolymerDeclaration extends HtmlElement {
}
var property = new Symbol(attr);
- var mirror = cls.declarations[property];
- if (mirror is MethodMirror) {
- if (!mirror.isGetter || !_hasSetter(cls, mirror)) mirror = null;
- } else if (mirror is! VariableMirror) {
- mirror = null;
- }
+ var mirror = _getProperty(cls, property);
if (mirror == null) {
window.console.warn('property for attribute $attr of polymer-element '
'name=$name not found.');
@@ -439,6 +434,8 @@ class PolymerDeclaration extends HtmlElement {
// If an element may take 6us to create, getCustomPropertyNames might
// cost 1.6us more.
void inferObservers(ClassMirror cls) {
+ if (cls == _objectType) return;
+ inferObservers(cls.superclass);
for (var method in cls.declarations.values) {
if (method is! MethodMirror || method.isStatic
|| !method.isRegularMethod) continue;
@@ -499,33 +496,26 @@ PolymerDeclaration _getDeclaration(String name) => _declarations[name];
final _objectType = reflectClass(Object);
+
Map _getPublishedProperties(ClassMirror cls, Map props) {
if (cls == _objectType) return props;
props = _getPublishedProperties(cls.superclass, props);
- for (var field in cls.declarations.values) {
- if (field is! VariableMirror ||
- field.isFinal || field.isStatic || field.isPrivate) continue;
-
- for (var meta in field.metadata) {
- if (meta.reflectee is PublishedProperty) {
- if (props == null) props = {};
- props[field.simpleName] = field;
- break;
- }
- }
- }
-
- for (var getter in cls.declarations.values) {
- if (getter is! MethodMirror || !getter.isGetter ||
- getter.isStatic || getter.isPrivate) continue;
-
- for (var meta in getter.metadata) {
- if (meta.reflectee is PublishedProperty) {
- if (_hasSetter(cls, getter)) {
- if (props == null) props = {};
- props[getter.simpleName] = getter;
+ for (var member in cls.declarations.values) {
+ if (member.isStatic || member.isPrivate) continue;
+
+ if (member is VariableMirror && !member.isFinal
+ || member is MethodMirror && member.isGetter) {
+
+ for (var meta in member.metadata) {
+ if (meta.reflectee is PublishedProperty) {
+ // Note: we delay the setter check until we find @published because
+ // it's a tad expensive.
+ if (member is! MethodMirror || _hasSetter(cls, member)) {
+ if (props == null) props = {};
+ props[member.simpleName] = member;
+ }
+ break;
}
- break;
}
}
}
@@ -533,6 +523,18 @@ Map _getPublishedProperties(ClassMirror cls, Map props) {
return props;
}
+DeclarationMirror _getProperty(ClassMirror cls, Symbol property) {
+ do {
+ var mirror = cls.declarations[property];
+ if (mirror is MethodMirror && mirror.isGetter && _hasSetter(cls, mirror)
+ || mirror is VariableMirror) {
+ return mirror;
+ }
+ cls = cls.superclass;
+ } while (cls != null);
+ return null;
+}
+
bool _hasSetter(ClassMirror cls, MethodMirror getter) {
var setterName = new Symbol('${MirrorSystem.getName(getter.simpleName)}=');
var mirror = cls.declarations[setterName];
« no previous file with comments | « pkg/pkg.status ('k') | pkg/polymer/lib/src/instance.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698