@@ -12,12 +12,13 @@ import {dashCaseToCamelCase} from '../util';
1212// Group 1 = "bind-"
1313// Group 2 = "var-" or "#"
1414// Group 3 = "on-"
15- // Group 4 = the identifier after "bind-", "var-/#", or "on-"
16- // Group 5 = idenitifer inside square braces
17- // Group 6 = identifier inside parenthesis
15+ // Group 4 = "bindon-"
16+ // Group 5 = the identifier after "bind-", "var-/#", or "on-"
17+ // Group 6 = idenitifer inside [()]
18+ // Group 7 = idenitifer inside []
19+ // Group 8 = identifier inside ()
1820var BIND_NAME_REGEXP = RegExpWrapper . create (
19- '^(?:(?:(?:(bind-)|(var-|#)|(on-))(.+))|\\[([^\\]]+)\\]|\\(([^\\)]+)\\))$' ) ;
20-
21+ '^(?:(?:(?:(bind-)|(var-|#)|(on-)|(bindon-))(.+))|\\[\\(([^\\)]+)\\)\\]|\\[([^\\]]+)\\]|\\(([^\\)]+)\\))$' ) ;
2122/**
2223 * Parses the property bindings on a single element.
2324 */
@@ -36,23 +37,30 @@ export class PropertyBindingParser extends CompileStep {
3637 MapWrapper . forEach ( attrs , ( attrValue , attrName ) => {
3738 var bindParts = RegExpWrapper . firstMatch ( BIND_NAME_REGEXP , attrName ) ;
3839 if ( isPresent ( bindParts ) ) {
39- if ( isPresent ( bindParts [ 1 ] ) ) {
40- // match: bind-prop
41- this . _bindProperty ( bindParts [ 4 ] , attrValue , current , newAttrs ) ;
42- } else if ( isPresent ( bindParts [ 2 ] ) ) {
43- // match: var-name / var-name="iden" / #name / #name="iden"
44- var identifier = bindParts [ 4 ] ;
40+ if ( isPresent ( bindParts [ 1 ] ) ) { // match: bind-prop
41+ this . _bindProperty ( bindParts [ 5 ] , attrValue , current , newAttrs ) ;
42+
43+ } else if ( isPresent ( bindParts [ 2 ] ) ) { // match: var-name / var-name="iden" / #name / #name="iden"
44+ var identifier = bindParts [ 5 ] ;
4545 var value = attrValue == '' ? '\$implicit' : attrValue ;
4646 this . _bindVariable ( identifier , value , current , newAttrs ) ;
47- } else if ( isPresent ( bindParts [ 3 ] ) ) {
48- // match: on-event
49- this . _bindEvent ( bindParts [ 4 ] , attrValue , current , newAttrs ) ;
50- } else if ( isPresent ( bindParts [ 5 ] ) ) {
51- // match: [ prop]
47+
48+ } else if ( isPresent ( bindParts [ 3 ] ) ) { // match: on-event
49+ this . _bindEvent ( bindParts [ 5 ] , attrValue , current , newAttrs ) ;
50+
51+ } else if ( isPresent ( bindParts [ 4 ] ) ) { // match: bindon- prop
5252 this . _bindProperty ( bindParts [ 5 ] , attrValue , current , newAttrs ) ;
53- } else if ( isPresent ( bindParts [ 6 ] ) ) {
54- // match: (event)
55- this . _bindEvent ( bindParts [ 6 ] , attrValue , current , newAttrs ) ;
53+ this . _bindAssignmentEvent ( bindParts [ 5 ] , attrValue , current , newAttrs ) ;
54+
55+ } else if ( isPresent ( bindParts [ 6 ] ) ) { // match: [(expr)]
56+ this . _bindProperty ( bindParts [ 6 ] , attrValue , current , newAttrs ) ;
57+ this . _bindAssignmentEvent ( bindParts [ 6 ] , attrValue , current , newAttrs ) ;
58+
59+ } else if ( isPresent ( bindParts [ 7 ] ) ) { // match: [expr]
60+ this . _bindProperty ( bindParts [ 7 ] , attrValue , current , newAttrs ) ;
61+
62+ } else if ( isPresent ( bindParts [ 8 ] ) ) { // match: (event)
63+ this . _bindEvent ( bindParts [ 8 ] , attrValue , current , newAttrs ) ;
5664 }
5765 } else {
5866 var expr = this . _parser . parseInterpolation (
@@ -90,6 +98,10 @@ export class PropertyBindingParser extends CompileStep {
9098 MapWrapper . set ( newAttrs , name , ast . source ) ;
9199 }
92100
101+ _bindAssignmentEvent ( name , expression , current :CompileElement , newAttrs ) {
102+ this . _bindEvent ( name , `${ expression } =$event` , current , newAttrs ) ;
103+ }
104+
93105 _bindEvent ( name , expression , current :CompileElement , newAttrs ) {
94106 current . bindElement ( ) . bindEvent (
95107 dashCaseToCamelCase ( name ) , this . _parser . parseAction ( expression , current . elementDescription )
0 commit comments