You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(platform-server): dynamic styles do not get converted from camelCase to kebab-case #19235
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
Using HostBinding or NgStyle with platform-server appends the style to the correct element, but does not convert the name of the style to kebab-case as platform-browser does. This leads the browser to not recognize the name of the style.
Expected behavior
The dynamically applied styles should be transferred to the DOM as kebab-case, not camelCase.
Minimal reproduction of the problem with instructions
Create a component and add a HostBinding for marginRight
Use @angular/cli to build a commonjs package
Render the package using nguniversal/express-engine
Turn off JS to prevent bootstrapping
Inspect the DOM to find the component with the incorrect styles
What is the motivation / use case for changing the behavior?
If a user has JS disabled, or if bootstrapping is particularly slow, UX is greatly impacted as styles are not correctly applied throughout the DOM.
Environment
Angular version: 5.0.0-beta.7
Browser:
- [ x ] Chrome (desktop) version 61.0.3163.79
For Tooling issues:
- Node version: 8.5.0
- Platform: Linux
In the browser implementation, the code looks like this, where the style is applied directly to the element, thus leveraging the browser's implicit transformation from camel case to dash case:
Activity
Toxicable commentedon Sep 17, 2017
Can confirm on v4.4.1 and v 5.0.0-beta.7
As a work around you can do
@HostBinding('style.margin-right')which works in my testingTo Reproduce:
git clone https://github.com/angular/universal-startercd cliadd to app.component.ts
<my-comp></my-comp>insideAppComponet's template withMyCompadded to theAppModule'sdeclarationsnpm run build:staticCaerusKaru commentedon Sep 19, 2017
It looks like the problem is here:
angular/packages/platform-server/src/parse5_adapter.ts
Lines 457 to 472 in 6279e50
In the browser implementation, the code looks like this, where the style is applied directly to the element, thus leveraging the browser's implicit transformation from camel case to dash case:
angular/packages/platform-browser/src/dom/dom_renderer.ts
Lines 182 to 189 in 1092292
jonbonraki commentedon Dec 14, 2017
Is any Body looking into this?
CaerusKaru commentedon Dec 14, 2017
If @vikerman is too swamped, I can probably get a PR in early next week. But I think he's the only one assigned at the moment.
fix(platform-server): generate correct stylings for camel case names
fix(platform-server): generate correct stylings for camel case names (#…
angular-automatic-lock-bot commentedon Sep 13, 2019
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.
fix(platform-server): generate correct stylings for camel case names (a…