docs: update Ivy compatibility guide to mention DebugElement behavior difference related to styling
See original GitHub issueπ bug report
Affected Package
Ivy renderer
Is this a regression?
Itβs working with ivy disabled
Description
A clear and concise description of the problem...π¬ Minimal Reproduction
In my component:
<span [style]="colorStyle"></span>
public get colorStyle(): { [key: string]: string } { return { 'background-color': '#026cdf' }; }
In my test:
it('should display the open color', () => { expect(getElement().styles['background-color']).toBe('#026cdf'); });
π₯ Exception or Error
Error: Expected 'rgb(2, 108, 223)' to be '#026cdf'
π Your Environment
Angular Version:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ β³ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 9.1.12
Node: 12.3.1
OS: darwin x64
Angular: 9.1.12
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.901.12
@angular-devkit/build-angular 0.901.12
@angular-devkit/build-optimizer 0.901.12
@angular-devkit/build-webpack 0.901.12
@angular-devkit/core 9.1.12
@angular-devkit/schematics 9.1.12
@angular/cdk 9.2.4
@angular/material 9.2.4
@ngtools/webpack 9.1.12
@schematics/angular 9.1.12
@schematics/update 0.901.12
rxjs 6.5.3
typescript 3.7.3
webpack 4.42.0
Anything else relevant?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Ivy compatibility guide - Angular
The Angular team has worked hard to ensure Ivy is as backwards-compatible with the previous rendering engine ("View Engine") as possible. However, in...
Read more >Component testing scenarios - Angular
This guide explores common component testing use cases. ... newEvent utility function (not provided by Angular) for better browser compatibility nameInput.
Read more >Angular 13 in Depth - SΓ©bastien Dubois
Note that the Angular CLI now prefers the ESM version of dependencies (if it is available). As a result of these changes, the...
Read more >@angular/compiler-cli | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >View Raw - UNPKG
Note also that this Observable runs outside of the Angular zone, ... To improve performance, we want to check and update the list...
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
Thanks for making the reproduction app! Heres what I found,
Without Ivy the PRE_R3 debug element stores the raw style value.
debugEl.styles[style] = value;
.debugEl.styles
is just a regular javascript object. https://github.com/angular/angular/blob/6768fe9927ad4b9b81c5f8094c42c771d1047f56/packages/core/src/view/services.ts#L818-L824With Ivy, the POST_R3 debug elementβs
styles
property shadows thestyle
property on the actual DOM node.This is why
fixture.debugElement.query(By.css("span")).styles["background-color"]
returns different values. Without Ivy the look up is done on a regular javascript object that has the raw style value. With Ivy the look up is done against theCSSStyleDeclaration
object on the actual DOM node (in this case the browser serialization that I described above applies).Youβll notice that in both cases, the actual inline style on the dom node is the same.
Without Ivy: With Ivy:
I would argue that the DebugElement behaviour in Ivy is preferable because it more closely adheres to the behaviour you would expect to see in your browser.
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.