This repository was archived by the owner on Feb 22, 2018. It is now read-only.
File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,13 @@ class DirectiveSelector {
57
57
});
58
58
}
59
59
60
+ String _camelcase (String s) {
61
+ var part = s.split ('-' ).map ((s) => s.toLowerCase ());
62
+ if (part.length <= 1 )
63
+ return part.join ();
64
+ return part.first + part.skip (1 ).map (capitalize).join ();
65
+ }
66
+
60
67
/**
61
68
* [matchElement] returns an [ElementBinder] or a [TemplateElementBinder] configured with all the
62
69
* directives triggered by the `node` .
@@ -92,7 +99,7 @@ class DirectiveSelector {
92
99
if (attrName.startsWith ("on-" )) {
93
100
builder.onEvents[attrName] = value;
94
101
} else if (attrName.startsWith (BIND_PREFIX )) {
95
- builder.bindAttrs[attrName.substring (BIND_PREFIX_LENGTH )] =
102
+ builder.bindAttrs[_camelcase ( attrName.substring (BIND_PREFIX_LENGTH ) )] =
96
103
_astParser (value, formatters: _formatters);
97
104
}
98
105
Original file line number Diff line number Diff line change @@ -70,10 +70,17 @@ main() {
70
70
71
71
72
72
it ('should bind to a non-existent property' , () {
73
+ registerElement ('tests-empty' , {});
74
+ compileAndUpgrade ('<tests-empty bind-newprop=27></tests-empty>' );
75
+ _.rootScope.apply ();
76
+ expect (customProp ('newprop' )).toEqual (27 );
77
+ });
78
+
79
+ it ('should bind to a camelCase property' , () {
73
80
registerElement ('tests-empty' , {});
74
81
compileAndUpgrade ('<tests-empty bind-new-prop=27></tests-empty>' );
75
82
_.rootScope.apply ();
76
- expect (customProp ('new-prop ' )).toEqual (27 );
83
+ expect (customProp ('newProp ' )).toEqual (27 );
77
84
});
78
85
79
86
it ('should bind to both directives and properties' , () {
You can’t perform that action at this time.
0 commit comments