Index: lib/src/common/polymer_descriptor.dart |
diff --git a/lib/src/common/polymer_descriptor.dart b/lib/src/common/polymer_descriptor.dart |
index f4457caeb8275be5c79b115b2f376c15e55a6d99..ba5ab24f197b5320ce22c27695c1b7a71e86e283 100644 |
--- a/lib/src/common/polymer_descriptor.dart |
+++ b/lib/src/common/polymer_descriptor.dart |
@@ -5,6 +5,7 @@ library polymer.src.micro.properties; |
import 'dart:js'; |
import 'package:reflectable/reflectable.dart'; |
+import 'behavior.dart'; |
import 'declarations.dart'; |
import 'js_proxy.dart'; |
import 'property.dart'; |
@@ -20,9 +21,10 @@ JsObject createPolymerDescriptor(Type type, PolymerRegister annotation) { |
'is': annotation.tagName, |
'extends': annotation.extendsTag, |
'hostAttributes': annotation.hostAttributes, |
- 'properties': buildPropertiesObject(type), |
+ 'properties': _buildPropertiesObject(type), |
'observers': _buildObserversObject(type), |
'listeners': _buildListenersObject(type), |
+ 'behaviors': _buildBehaviorsList(type), |
'__isPolymerDart__': true, |
}; |
_setupLifecycleMethods(type, object); |
@@ -44,7 +46,7 @@ Map<String, DeclarationMirror> propertyDeclarationsFor(Type type) { |
} |
// Set up the `properties` descriptor object. |
-Map buildPropertiesObject(Type type) { |
+Map _buildPropertiesObject(Type type) { |
var declarations = propertyDeclarationsFor(type); |
var properties = {}; |
declarations.forEach((String name, DeclarationMirror declaration) { |
@@ -187,6 +189,23 @@ Map _getPropertyInfoForType(Type type, DeclarationMirror declaration) { |
return property; |
} |
+/// List of [JsObjects]s representing the behaviors for an element. |
+List<JsObject> _buildBehaviorsList(Type type) { |
+ var behaviors = <JsObject>[]; |
+ |
+ isBehavior(instance) => instance is BehaviorInterface; |
+ |
+ var interfaces = mixinsFor(type, jsProxyReflectable, |
Siggi Cherem (dart-lang)
2015/08/12 22:43:15
Seems like we are visiting each behavior annotatio
jakemac
2015/08/13 17:50:45
I didn't add mixinForEach, but I did modify it to
|
+ where: (ClassMirror mixin) => mixin.metadata.any(isBehavior)); |
+ for (var interface in interfaces) { |
+ behaviors.add( |
+ (interface.metadata.firstWhere(isBehavior) as BehaviorInterface) |
+ .getBehavior(interface.reflectedType)); |
+ } |
+ |
+ return behaviors.isEmpty ? null : behaviors; |
+} |
+ |
/// Given a [Type] return the [JsObject] representation of that type. |
/// TODO(jakemac): Make this more robust, specifically around Lists. |
dynamic jsType(Type type) { |