refactor(ivy): Switch styling to reconcile algorithm#34616
Conversation
7662302 to
0a96469
Compare
0a96469 to
35c3645
Compare
35c3645 to
3e4f380
Compare
3e4f380 to
fb4855d
Compare
fb4855d to
b6478a4
Compare
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
b6478a4 to
099f4bc
Compare
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
099f4bc to
36720db
Compare
pkozlowski-opensource
left a comment
There was a problem hiding this comment.
Another batch of reviews - this time mostly for the existing acceptance tests (packages/core/test/acceptance/styling_spec.ts)
| @@ -829,6 +1190,14 @@ describe('styling', () => { | |||
| expect(element.style.opacity).toBeFalsy(); | |||
There was a problem hiding this comment.
The 2 above asserts don't look right too me (and sound like a breaking change wrt to VE). The previous contract was that any falsy value meant "remove" while now it seems to mean "I don't have an opinion". But this doesn't totally right to me as a developer has an opinion.
I think this change counter-intuitive and breaking. Could we discuss it more?
There was a problem hiding this comment.
- yes this is technically a breaking change.
- you can think of
nullvsundefinedas a new feature. It is being introduced now, because doing it later will be harder, because as people will start using priorities they will usenullorundefinedinterchangeably which will make introducing this feature harder. - Let's discuss on VC with @kara
| // there is no need to flush styling since the styles are applied directly | ||
| expect(ngDevMode !.flushStyling).toEqual(0); | ||
| // once for the template flush and again for the host bindings | ||
| expect(ngDevMode !.flushStyling).toEqual(2); |
There was a problem hiding this comment.
nit: most of this test should pass in VE as well - maybe remove onlyInIvy from it and only guard this assert ?
There was a problem hiding this comment.
- It is not clear to me which
onlyInIvydo you want me to remove (Should I remove all and see which tests pass?) - I thought per earlier comment you did not like when I put conditional asserts between VE/Ivy.
Sorry I am just confused as to what I should do here.
| fixture.detectChanges(); | ||
|
|
||
| expect(element.style.width).toEqual('200px'); | ||
| expect(element.style.width).toEqual('300px'); |
There was a problem hiding this comment.
I would love to re-discuss undefined vs. null, especially wrt to the style bindings prioritisation. This assert seems off to me.
There was a problem hiding this comment.
- Let's discuss
- What is wrong with the assert? (Test pass, looks right to me)
| expect(div1.className).toEqual('s1'); | ||
| // VE has weird behavior where it calls the @Input('class') with either `class="static` or | ||
| // `[class]="dynamic"` but never both. This is determined at compile time. Due to locality we | ||
| // don't know if `[class]` is coming if we see `class` only. So we need to combine the two |
There was a problem hiding this comment.
For the future consideration / helping to re-word the comment / stating the obvious: this behaviour is not specific to class / [class] but applies to any property binding that has a corresponding attribute... This is another manifestation of the syntax / "shadowing rules" where the left-hand side doesn't identify binding target precisely enough. In this sense VE is not particularly "weird" - it is just how the syntax works / can be abused atm....
There was a problem hiding this comment.
It is specific to class in the sense that we do the concatenation only in class.
It is unclear what is my action item here.
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
Compiler keeps track of number of slots (`vars`) which are needed for binding instructions. Normally each binding instructions allocates a single slot in the `LView` but styling instructions need to allocate two slots. PR Close angular#34616
…g bindings" (angular#34616) This change reverts angular#28711 NOTE: This change deletes code and creates a BROKEN SHA. If reverting this SHA needs to be reverted with the next SHA to get back into a valid state. The change removes the fact that `NgStyle`/`NgClass` is special and colaborates with the `[style]`/`[class]` to merge its styles. By reverting to old behavior we have better backwards compatiblity since it is no longer treated special and simply overwrites the styles (same as VE) PR Close angular#34616
…4616) NOTE: This change deletes code and creates a BROKEN SHA. If reverting this SHA needs to be reverted with the next SHA to get back into a valid state. PR Close angular#34616
NOTE: This change must be reverted with previous deletes so that it code remains in build-able state. This change deletes old styling code and replaces it with a simplified styling algorithm. The mental model for the new algorithm is: - Create a linked list of styling bindings in the order of priority. All styling bindings ere executed in compiled order and than a linked list of bindings is created in priority order. - Flush the style bindings at the end of `advance()` instruction. This implies that there are two flush events. One at the end of template `advance` instruction in the template. Second one at the end of `hostBindings` `advance` instruction when processing host bindings (if any). - Each binding instructions effectively updates the string to represent the string at that location. Because most of the bindings are additive, this is a cheap strategy in most cases. In rare cases the strategy requires removing tokens from the styling up to this point. (We expect that to be rare case)S Because, the bindings are presorted in the order of priority, it is safe to resume the processing of the concatenated string from the last change binding. PR Close angular#34616
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
There was a problem hiding this comment.
It looks like we are keeping the "head" marker pointing to the "template head" and inserting new host bindings into the middle (in front of the template head but behind previous host bindings). I take it we are not prepending host bindings to maintain their priority order (last directive has highest priority)?
There was a problem hiding this comment.
I don't fully follow your question.
The items get inserted into the list in a way which results bindings to be sorted in priority order.
This means that component/directive get inserted in front of e "head" so that the final list has the desired order.
Should we VC?
There was a problem hiding this comment.
Probably easier to discuss over VC, yeah. I was asking why we insert new host bindings behind previous host bindings but before template bindings (instead of just prepending to the very beginning)
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
|
Merged into styling |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
refactor(ivy): Switch styling to reconcile algorithmThis change deletes old styling code and replaces it with a simplified styling algorithm.
The mental model for the new algorithm is:
advance()instruction. This implies that there are two flush events. One at the end of templateadvanceinstruction in the template. Second one at the end ofhostBindingsadvanceinstruction when processing host bindings (if any).PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information