Repository navigation
Closed
Labels
area: coreIssues related to the framework runtimecore: styling bindingsfeatureLabel used to distinguish feature request from other issuesfreq1: low
Milestone
Description
🐞 bug report
Affected Package
The issue is caused by package @angular/common
Is this a regression?
NoDescription
When I am trying to use class binding on an element with multiple classes and each key has more than one class names (e.g. classA classB), I get an error.
🔬 Minimal Reproduction
Reproduction steps:
- Open the Angular application and run
ng serveto run it - Open the file
app.component.ts - Change the
ngClassdirective of theh1element to class binding[class] - Inspect the console of the browser for errors
🔥 Exception or Error
core.js:5873 ERROR DOMException: Failed to execute 'add' on 'DOMTokenList': The token provided ('classA classB') contains HTML space characters, which are not valid in tokens.
at DefaultDomRenderer2.addClass (http://localhost:4200/vendor.js:51138:39)
at applyStyling (http://localhost:4200/vendor.js:20043:49)
at updateStyling (http://localhost:4200/vendor.js:28890:9)
at updateStylingMap (http://localhost:4200/vendor.js:28841:13)
at checkStylingMap (http://localhost:4200/vendor.js:28370:13)
at Module.ɵɵclassMap (http://localhost:4200/vendor.js:28260:5)
at AppComponent_Template (http://localhost:4200/main.js:119:65)
at executeTemplate (http://localhost:4200/vendor.js:17342:9)
at refreshView (http://localhost:4200/vendor.js:17189:13)
at refreshComponent (http://localhost:4200/vendor.js:18629:9)
🌍 Your Environment
Angular Version:
Angular CLI: 9.0.4 Node: 12.16.0 OS: win32 x64 Angular: 9.0.4 ... animations, cli, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router Ivy Workspace: Yes Package Version ----------------------------------------------------------- @angular-devkit/architect 0.900.4 @angular-devkit/build-angular 0.900.4 @angular-devkit/build-optimizer 0.900.4 @angular-devkit/build-webpack 0.900.4 @angular-devkit/core 9.0.4 @angular-devkit/schematics 9.0.4 @ngtools/webpack 9.0.4 @schematics/angular 9.0.4 @schematics/update 0.900.4 rxjs 6.5.4 typescript 3.7.5 webpack 4.41.2
Anything else relevant?
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimecore: styling bindingsfeatureLabel used to distinguish feature request from other issuesfreq1: low
Activity
pkozlowski-opensource commentedon Mar 4, 2020
Live reproduction: https://ng-run.com/edit/TBihA8CFw9O70KgPtnLQ
@bampakoa currently there are number of gaps in the functionality between
[ngClass]and[class]bindings. In the long term we want to unify those but we are definitively not there yet. As such you can't at this point, expect that both will be equivalent.Is there any particular reason that you would prefer to using
[class]vs.[ngClass]?bampakoa commentedon Mar 4, 2020
@pkozlowski-opensource no, not anything particular.I read in the docs that
I think that the documentation at this point should be improved for the corner case that I mentioned.
jelbourn commentedon Jan 28, 2021
Closing this since, for the time being, we don't plan to bridge the feature differences between
NgClassand[class], but we should definitely document the gap, tracked in #40623angular-automatic-lock-bot commentedon Feb 28, 2021
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.