fix(compiler): don’t throw for empty array literal in assignments (#14878)
Closes #14782
This commit is contained in:
		
							parent
							
								
									6bc6482765
								
							
						
					
					
						commit
						6cd3326b55
					
				| @ -320,7 +320,7 @@ export class AstTransformer implements AstVisitor { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   visitPropertyWrite(ast: PropertyWrite, context: any): AST { |   visitPropertyWrite(ast: PropertyWrite, context: any): AST { | ||||||
|     return new PropertyWrite(ast.span, ast.receiver.visit(this), ast.name, ast.value); |     return new PropertyWrite(ast.span, ast.receiver.visit(this), ast.name, ast.value.visit(this)); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   visitSafePropertyRead(ast: SafePropertyRead, context: any): AST { |   visitSafePropertyRead(ast: SafePropertyRead, context: any): AST { | ||||||
|  | |||||||
| @ -619,6 +619,14 @@ export function main() { | |||||||
|              expect(ctx.componentInstance.a).toEqual(2); |              expect(ctx.componentInstance.a).toEqual(2); | ||||||
|            })); |            })); | ||||||
| 
 | 
 | ||||||
|  |         it('should support empty literals', fakeAsync(() => { | ||||||
|  |              const ctx = _bindSimpleProp('(event)="a=[{},[]]"'); | ||||||
|  |              const childEl = ctx.debugElement.children[0]; | ||||||
|  |              childEl.triggerEventHandler('event', 'EVENT'); | ||||||
|  | 
 | ||||||
|  |              expect(ctx.componentInstance.a).toEqual([{}, []]); | ||||||
|  |            })); | ||||||
|  | 
 | ||||||
|         it('should throw when trying to assign to a local', fakeAsync(() => { |         it('should throw when trying to assign to a local', fakeAsync(() => { | ||||||
|              expect(() => { |              expect(() => { | ||||||
|                _bindSimpleProp('(event)="$event=1"'); |                _bindSimpleProp('(event)="$event=1"'); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user