Skip to content
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

Angular property binding begin with colon should throw error #44185

Open
Zuckjet opened this issue Nov 16, 2021 · 3 comments
Open

Angular property binding begin with colon should throw error #44185

Zuckjet opened this issue Nov 16, 2021 · 3 comments
Labels
area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime compiler: parser P4 A relatively minor issue that is not relevant to core functions
Milestone

Comments

@Zuckjet
Copy link
Contributor

Zuckjet commented Nov 16, 2021

Which @angular/* package(s) are the source of the bug?

compiler

Is this a regression?

No

Description

with this code, Angular will treat the button as disabled(xxxx is any random string)

<button :disabled="xxxx">Disabled Button</button>

First, is there any document that Angular support this code style begin with colon(:) for property binding ?
If not, I think it is better to throw error

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

No response

Anything else?

No response

@Narasim0406
Copy link

In angular for property binding, you should use [] not the colon.Please see the documentation over here.

<button [disabled]="xxxx">Disabled Button

@Zuckjet
Copy link
Contributor Author

Zuckjet commented Nov 16, 2021

I know I should use [], but I think this behavior is weird.

this code sample run in plain html will not disable button, but in angular it will. If angular doesn't support this syntax(begin with :), why not just throw compile error or keep the same behavior with plain html ?

@AndrewKushnir AndrewKushnir added area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime labels Nov 16, 2021
@ngbot ngbot bot added this to the needsTriage milestone Nov 16, 2021
@JoostK
Copy link
Member

JoostK commented Nov 16, 2021

The colon is interpreted as XML namespace separator, where the namespace prefix is left empty. That is not valid according to the XML specification, but Angular's parser/compiler accepts it to mean the default namespace.

@JoostK JoostK added compiler: parser P4 A relatively minor issue that is not relevant to core functions labels Nov 16, 2021
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Nov 16, 2021
Zuckjet added a commit to Zuckjet/angular that referenced this issue Nov 17, 2021
when attribute begin with colon, it should not be parsed as namespace since namespce is empty

PR Close angular#44185
Zuckjet added a commit to Zuckjet/angular that referenced this issue Nov 17, 2021
when attribute begin with colon, it should not be parsed as namespace since namespce is empty

PR Close angular#44185
Zuckjet added a commit to Zuckjet/angular that referenced this issue Nov 17, 2021
when attribute begin with colon, it should not be parsed as namespace since namespce is empty

PR Close angular#44185
Zuckjet added a commit to Zuckjet/angular that referenced this issue Feb 4, 2022
when attribute begin with colon, it should not be parsed as namespace since namespce is empty

PR Close angular#44185
Zuckjet added a commit to Zuckjet/angular that referenced this issue Feb 16, 2022
when attribute begin with colon, it should not be parsed as namespace since namespce is empty

PR Close angular#44185
Zuckjet added a commit to Zuckjet/angular that referenced this issue Feb 16, 2022
when attribute begin with colon, it should not be parsed as namespace

PR Close angular#44185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime compiler: parser P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants