@@ -51,7 +51,7 @@ export class BindingParser {
5151 const expression = properties [ propName ] ;
5252 if ( typeof expression === 'string' ) {
5353 this . parsePropertyBinding (
54- propName , expression , true , sourceSpan , sourceSpan . start . offset , undefined , [ ] ,
54+ propName , expression , true , false , sourceSpan , sourceSpan . start . offset , undefined , [ ] ,
5555 // Use the `sourceSpan` for `keySpan`. This isn't really accurate, but neither is the
5656 // sourceSpan, as it represents the sourceSpan of the host itself rather than the
5757 // source of the host binding (which doesn't exist in the template). Regardless,
@@ -169,7 +169,8 @@ export class BindingParser {
169169 const srcSpan = isIvyAst ? bindingSpan : sourceSpan ;
170170 const valueSpan = moveParseSourceSpan ( sourceSpan , binding . value . ast . sourceSpan ) ;
171171 this . _parsePropertyAst (
172- key , binding . value , srcSpan , keySpan , valueSpan , targetMatchableAttrs , targetProps ) ;
172+ key , binding . value , false , srcSpan , keySpan , valueSpan , targetMatchableAttrs ,
173+ targetProps ) ;
173174 } else {
174175 targetMatchableAttrs . push ( [ key , '' /* value */ ] ) ;
175176 // Since this is a literal attribute with no RHS, source span should be
@@ -239,8 +240,8 @@ export class BindingParser {
239240 }
240241
241242 parsePropertyBinding (
242- name : string , expression : string , isHost : boolean , sourceSpan : ParseSourceSpan ,
243- absoluteOffset : number , valueSpan : ParseSourceSpan | undefined ,
243+ name : string , expression : string , isHost : boolean , isPartOfAssignmentBinding : boolean ,
244+ sourceSpan : ParseSourceSpan , absoluteOffset : number , valueSpan : ParseSourceSpan | undefined ,
244245 targetMatchableAttrs : string [ ] [ ] , targetProps : ParsedProperty [ ] , keySpan : ParseSourceSpan ) {
245246 if ( name . length === 0 ) {
246247 this . _reportError ( `Property name is missing in binding` , sourceSpan ) ;
@@ -272,7 +273,8 @@ export class BindingParser {
272273 } else {
273274 this . _parsePropertyAst (
274275 name , this . parseBinding ( expression , isHost , valueSpan || sourceSpan , absoluteOffset ) ,
275- sourceSpan , keySpan , valueSpan , targetMatchableAttrs , targetProps ) ;
276+ isPartOfAssignmentBinding , sourceSpan , keySpan , valueSpan , targetMatchableAttrs ,
277+ targetProps ) ;
276278 }
277279 }
278280
@@ -284,19 +286,21 @@ export class BindingParser {
284286 const expr = this . parseInterpolation ( value , valueSpan || sourceSpan , interpolatedTokens ) ;
285287 if ( expr ) {
286288 this . _parsePropertyAst (
287- name , expr , sourceSpan , keySpan , valueSpan , targetMatchableAttrs , targetProps ) ;
289+ name , expr , false , sourceSpan , keySpan , valueSpan , targetMatchableAttrs , targetProps ) ;
288290 return true ;
289291 }
290292 return false ;
291293 }
292294
293295 private _parsePropertyAst (
294- name : string , ast : ASTWithSource , sourceSpan : ParseSourceSpan , keySpan : ParseSourceSpan ,
295- valueSpan : ParseSourceSpan | undefined , targetMatchableAttrs : string [ ] [ ] ,
296- targetProps : ParsedProperty [ ] ) {
296+ name : string , ast : ASTWithSource , isPartOfAssignmentBinding : boolean ,
297+ sourceSpan : ParseSourceSpan , keySpan : ParseSourceSpan , valueSpan : ParseSourceSpan | undefined ,
298+ targetMatchableAttrs : string [ ] [ ] , targetProps : ParsedProperty [ ] ) {
297299 targetMatchableAttrs . push ( [ name , ast . source ! ] ) ;
298- targetProps . push (
299- new ParsedProperty ( name , ast , ParsedPropertyType . DEFAULT , sourceSpan , keySpan , valueSpan ) ) ;
300+ targetProps . push ( new ParsedProperty (
301+ name , ast ,
302+ isPartOfAssignmentBinding ? ParsedPropertyType . TWO_WAY : ParsedPropertyType . DEFAULT ,
303+ sourceSpan , keySpan , valueSpan ) ) ;
300304 }
301305
302306 private _parseAnimation (
@@ -387,7 +391,8 @@ export class BindingParser {
387391 boundPropertyName = mapPropertyName ? mappedPropName : boundProp . name ;
388392 securityContexts = calcPossibleSecurityContexts (
389393 this . _schemaRegistry , elementSelector , mappedPropName , false ) ;
390- bindingType = BindingType . Property ;
394+ bindingType =
395+ boundProp . type === ParsedPropertyType . TWO_WAY ? BindingType . TwoWay : BindingType . Property ;
391396 if ( ! skipValidation ) {
392397 this . _validatePropertyOrAttributeName ( mappedPropName , boundProp . sourceSpan , false ) ;
393398 }
@@ -465,7 +470,8 @@ export class BindingParser {
465470 const ast = this . _parseAction ( expression , isAssignmentEvent , handlerSpan ) ;
466471 targetMatchableAttrs . push ( [ name ! , ast . source ! ] ) ;
467472 targetEvents . push ( new ParsedEvent (
468- eventName , target , ParsedEventType . Regular , ast , sourceSpan , handlerSpan , keySpan ) ) ;
473+ eventName , target , isAssignmentEvent ? ParsedEventType . TwoWay : ParsedEventType . Regular ,
474+ ast , sourceSpan , handlerSpan , keySpan ) ) ;
469475 // Don't detect directives for event names for now,
470476 // so don't add the event name to the matchableAttrs
471477 }
0 commit comments