Add extended diagnostic to warn when an attribute is not interpreted as a binding
See original GitHub issueWhich @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Angular does not properly bind an attribute when using attr.foo
syntax if there is no interpolation present in the value.
For example, this does not work:
<div attr.foo="bar"></div> <!-- erroneously keeps the attribute as "attr.foo" -->
This DOES work:
<div attr.foo="{{myProp}}"></div>
This also works:
<div [attr.foo]="'bar'"></div>
Please provide a link to a minimal reproduction of the bug
Please provide the exception or error you saw
The attribute is not set properly on the element using `attr.foo` syntax when no interpolation is present.
Please provide the environment you discovered this bug in (run ng version
)
The reproduction link is using Angular 13, but I also encountered this in my project which produces the following output for `ng version`:
Angular CLI: 12.2.16
Node: 14.19.3
Package Manager: npm 6.14.17
OS: darwin x64
Angular: 12.2.16
... animations, cli, common, compiler, compiler-cli, core
... elements, forms, language-service, localize
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1202.16
@angular-devkit/build-angular 12.2.16
@angular-devkit/core 12.2.16
@angular-devkit/schematics 12.2.16
@angular/cdk 12.2.13
@schematics/angular 12.2.16
ng-packagr 12.2.7
rxjs 6.6.3
typescript 4.3.5
webpack 5.50.0
### Anything else?
I encountered this in my project previously on Angular 11 as well.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Extended Diagnostics - Angular
Extended diagnostics are warnings by default and do not block compilation. Each diagnostic can be configured as either: warning (default) - The compiler...
Read more >Diagnostic flags in Clang — Clang 16.0.0git documentation
This diagnostic flag exists for GCC compatibility, and has no effect in Clang. -Waix-compat¶. This diagnostic is enabled by default. Diagnostic text: warning: ......
Read more >Bindings for Durable Functions - Azure | Microsoft Learn
The Durable Functions extension introduces three trigger bindings that control the execution of orchestrator, entity, and activity functions ...
Read more >Error and Warning Options (The GNU Fortran Compiler)
Error and Warning Options (The GNU Fortran Compiler) ... Warnings are diagnostic messages that report constructions which are not ... -Wc-binding-type. Warn ......
Read more >XSL Transformations (XSLT) Version 3.0 - W3C
3.1 XSLT Namespace; 3.2 Extension Attributes; 3.3 XSLT Media Type ... may produce warning messages if the constraint is not satisfied, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@atscott yeh, I didn’t close this one as I can totally see how it could be confusing. For a user it is not at all clear why
attr.x="{{exp}}"
setsx
attribute andattr.x="static"
setsattr.x
. In a sense the left-hand side of the assignment (target) changes based on the rhs and I would consider this surprising. So it “works as designed” but probably not “as expected”.As an alternative to warning we could just set the
x
attribute for theattr.x="static"
case.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.