8000 Template Expression Parsing Breaks When Using ES2015 Object Literal Properties Shorthand · Issue #10277 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content

Template Expression Parsing Breaks When Using ES2015 Object Literal Properties Shorthand #10277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
efreiberg opened this issue Jul 25, 2016 · 5 comments
Assignees
Labels
area: core Issues related to the framework runtime core: binding & interpolation Issue related to property/attribute binding or text interpolation feature: in backlog Feature request for which voting has completed and is now in the backlog feature Issue that requests a new feature P4 A relatively minor issue that is not relevant to core functions state: has PR
Milestone

Comments

@efreiberg
Copy link

I'm submitting a ... (check one with "x")

[] bug report
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
HTML espression parsing throws an exception when using object literal shorthand syntax. When attempting to use this syntax, I get the following error.

<template [ngTemplateOutlet]="templateRef" [ngOutletContext]="{ item }"></template>

Throws:

EXCEPTION: Template parse errors: Parser Error: Missing expected : at column 8 in [{ item }] in App@4:47 (" <h2>{{_item}}</h2> </template> <template [ngTemplateOutlet]="templateRef" [ERROR ->][ngOutletContext]="{ item }"></template> "): App@4:47 VM9574 platform-browser.umd.js:1900 EXCEPTION: Template parse errors: Parser Error: Missing expected : at column 8 in [{ item }] in App@4:47 (" <h2>{{_item}}</h2> </template> <template [ngTemplateOutlet]="templateRef" [ERROR ->][ngOutletContext]="{ item }"></template> "): App@4:47BrowserDomAdapter.logError @ VM9574 platform-browser.umd.js:1900BrowserDomAdapter.logGroup @ VM9574 platform-browser.umd.js:1910ExceptionHandler.call @ VM9573 core.umd.js:4329(anonymous function) @ VM9573 core.umd.js:9844ZoneDelegate.invoke @ VM9533 zone.js:323onInvoke @ VM9573 core.umd.js:9100ZoneDelegate.invoke @ VM9533 zone.js:322Zone.run @ VM9533 zone.js:216(anonymous function) @ VM9533 zone.js:571ZoneDelegate.invokeTask @ VM9533 zone.js:356onInvokeTask @ VM9573 core.umd.js:9091ZoneDelegate.invokeTask @ VM9533 zone.js:355Zone.runTask @ VM9533 zone.js:256drainMicroTaskQueue @ VM9533 zone.js:474ZoneTask.invoke @ VM9533 zone.js:426 ...

Expected/desired behavior
Object literal shorthand parsing is supported. Ex. { foo } is equivalent to { foo: foo }.

Reproduction of the problem
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).

https://plnkr.co/edit/J89FfkINlII9t3gaHG7J

What is the motivation / use case for changing the behavior?
This is valid object literal syntax, currently supported by transpilers and natively by evergreen browsers(Minus IE 10/11 and Safari 8).

Please tell us about your environment:

  • Angular version: 2.0.0-rc.4
  • Browser: Chrome 51.0.2704.106
  • Language: TypeScript 1.8.10

Other Information
In @angular/compiler/expression_parser, the
parseLiteralMap() method of the _ParseAST class doesn't handle the literal shorthand syntax.

@zoechi
Copy link
Contributor
zoechi commented Jul 25, 2016

Binding syntax isn't supposed to support full ESx syntax. There are several other things that are not supported.

@vicb
Copy link
Contributor
vicb commented Jul 26, 2016

It should not be too hard to add but don't expect this before or in 2.0

@SpeedoPasanen
Copy link

Hi, was this forgotten / ever coming? I know it's a very minor thing, but anything that makes writing templates even a bit cleaner is for the good. :)

@pkozlowski-opensource pkozlowski-opensource added the core: binding & interpolation Issue related to property/attribute binding or text interpolation label Mar 6, 2020
@jelbourn jelbourn added P4 A relatively minor issue that is not relevant to core functions and removed severity1: confusing labels Oct 1, 2020
@crisbeto crisbeto self-assigned this May 30, 2021
@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Jun 4, 2021
@angular-robot
Copy link
Contributor
angular-robot bot commented Jun 4, 2021

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@crisbeto crisbeto removed the feature: votes required Feature request which is currently still in the voting phase label Jun 4, 2021
@AndrewKushnir AndrewKushnir added the feature: in backlog Feature request for which voting has completed and is now in the backlog label Jun 4, 2021
crisbeto added a commit to crisbeto/angular that referenced this issue Jun 19, 2021
…mplates

Adds support for shorthand property declarations inside Angular templates. E.g. doing `{foo, bar}` instead of `{foo: foo, bar: bar}`.

Fixes angular#10277.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime core: binding & interpolation Issue related to property/attribute binding or text interpolation feature: in backlog Feature request for which voting has completed and is now in the backlog feature Issue that requests a new feature P4 A relatively minor issue that is not relevant to core functions state: has PR
Projects
None yet
10 participants
0