Skip to content

Conversation

@mhevery
Copy link
Contributor

@mhevery mhevery commented Jan 23, 2020

This change changes the priority order of static styling.

Current priority:

(least priority)
- Static 
  - Component
  - Directives
  - Template
- Dynamic Binding
  - Component
    - Map/Interpolation
    - Property
  - Directives
    - Map/Interpolation
    - Property
  - Template
    - Map/Interpolation
    - Property
(highest priority)

The issue with the above priority is this use case:

<div style="color: red;" directive-which-sets-color-blue>

In the above case the directive will win and the resulting color will be blue. However a small change of adding interpolation to the example like so. (Style interpolation is coming in #34202)

<div style="color: red; width: {{exp}}px" directive-which-sets-color-blue>

Changes the priority from static binding to interpolated binding which means now the resulting color is red. It is very surprising that adding an unrelated interpolation and style can change the color which was not changed. To fix that we need to make sure that the static values are associated with priority of the source (directive or template) where they were declared. The new resulting priority is:

(least priority)
- Component
  - Static
  - Map/Interpolation
  - Property
- Directives
  - Static
  - Map/Interpolation
  - Property
- Template
  - Static
  - Map/Interpolation
  - Property
(highest priority)

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@mhevery mhevery force-pushed the styling-static branch 3 times, most recently from 2127b9f to fb16cd7 Compare January 26, 2020 20:30
@mhevery mhevery requested a review from kara January 26, 2020 20:31
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@angular angular deleted a comment from googlebot Jan 26, 2020
@mhevery mhevery marked this pull request as ready for review January 26, 2020 20:31
@mhevery mhevery requested review from a team as code owners January 26, 2020 20:31
@mhevery mhevery added comp: ivy target: patch This PR is targeted for the next patch release labels Jan 26, 2020
@ngbot ngbot bot modified the milestone: needsTriage Jan 26, 2020
@mhevery
Copy link
Contributor Author

mhevery commented Jan 26, 2020

presubmit

@mhevery mhevery force-pushed the styling-static branch 3 times, most recently from 42e1416 to c4459fb Compare January 26, 2020 23:00
@mhevery mhevery requested a review from a team January 26, 2020 23:00
@AndrewKushnir
Copy link
Contributor

Global Ivy Presubmit

Copy link
Member

@pkozlowski-opensource pkozlowski-opensource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first round of comments from the first pass. I must say that I wasn't able to de-cipher all the details of the data structures used and the algorithm. I guess we should sync-up so you can walk me through it so I've got some more background.

At the same I didn't notice anything that would look "wrong", so we are for a good start here!

@AndrewKushnir
Copy link
Contributor

Global Ivy Presubmit #2

@mhevery mhevery force-pushed the styling-static branch 3 times, most recently from a6083ec to 03779b3 Compare January 28, 2020 21:22
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for merge, though we will do some additional cleanup (docs, any stylistic nits, etc) in a follow-up

@mhevery
Copy link
Contributor Author

mhevery commented Jan 29, 2020

presubmit

…ctive it belongs to

This change changes the priority order of static styling.

Current priority:
```
(least priority)
- Static
  - Component
  - Directives
  - Template
- Dynamic Binding
  - Component
    - Map/Interpolation
    - Property
  - Directives
    - Map/Interpolation
    - Property
  - Template
    - Map/Interpolation
    - Property
(highest priority)
```

The issue with the above priority is this use case:

```
<div style="color: red;" directive-which-sets-color-blue>
```
In the above case the directive will win and the resulting color will be `blue`. However a small change of adding interpolation to the example like so. (Style interpolation is coming in angular#34202)
```
<div style="color: red; width: {{exp}}px" directive-which-sets-color-blue>
```
Changes the priority from static binding to interpolated binding which means now the resulting color is `red`. It is very surprising that adding an unrelated interpolation and style can change the `color` which was not changed. To fix that we need to make sure that the static values are associated with priority of the source (directive or template) where they were declared. The new resulting priority is:

```
(least priority)
- Component
  - Static
  - Map/Interpolation
  - Property
- Directives
  - Static
  - Map/Interpolation
  - Property
- Template
  - Static
  - Map/Interpolation
  - Property
(highest priority)
```
@mhevery mhevery added the action: merge The PR is ready for merge by the caretaker label Jan 29, 2020
AndrewKushnir pushed a commit that referenced this pull request Jan 29, 2020
…ctive it belongs to (#34938)

This change changes the priority order of static styling.

Current priority:
```
(least priority)
- Static
  - Component
  - Directives
  - Template
- Dynamic Binding
  - Component
    - Map/Interpolation
    - Property
  - Directives
    - Map/Interpolation
    - Property
  - Template
    - Map/Interpolation
    - Property
(highest priority)
```

The issue with the above priority is this use case:

```
<div style="color: red;" directive-which-sets-color-blue>
```
In the above case the directive will win and the resulting color will be `blue`. However a small change of adding interpolation to the example like so. (Style interpolation is coming in #34202)
```
<div style="color: red; width: {{exp}}px" directive-which-sets-color-blue>
```
Changes the priority from static binding to interpolated binding which means now the resulting color is `red`. It is very surprising that adding an unrelated interpolation and style can change the `color` which was not changed. To fix that we need to make sure that the static values are associated with priority of the source (directive or template) where they were declared. The new resulting priority is:

```
(least priority)
- Component
  - Static
  - Map/Interpolation
  - Property
- Directives
  - Static
  - Map/Interpolation
  - Property
- Template
  - Static
  - Map/Interpolation
  - Property
(highest priority)
```

PR Close #34938
AndrewKushnir pushed a commit that referenced this pull request Jan 29, 2020
…ctive it belongs to (#34938)

This change changes the priority order of static styling.

Current priority:
```
(least priority)
- Static
  - Component
  - Directives
  - Template
- Dynamic Binding
  - Component
    - Map/Interpolation
    - Property
  - Directives
    - Map/Interpolation
    - Property
  - Template
    - Map/Interpolation
    - Property
(highest priority)
```

The issue with the above priority is this use case:

```
<div style="color: red;" directive-which-sets-color-blue>
```
In the above case the directive will win and the resulting color will be `blue`. However a small change of adding interpolation to the example like so. (Style interpolation is coming in #34202)
```
<div style="color: red; width: {{exp}}px" directive-which-sets-color-blue>
```
Changes the priority from static binding to interpolated binding which means now the resulting color is `red`. It is very surprising that adding an unrelated interpolation and style can change the `color` which was not changed. To fix that we need to make sure that the static values are associated with priority of the source (directive or template) where they were declared. The new resulting priority is:

```
(least priority)
- Component
  - Static
  - Map/Interpolation
  - Property
- Directives
  - Static
  - Map/Interpolation
  - Property
- Template
  - Static
  - Map/Interpolation
  - Property
(highest priority)
```

PR Close #34938
mhevery added a commit to mhevery/angular that referenced this pull request Jan 30, 2020
`TNode.directives` was introduced in angular#34938. Turns out that it is unnecessary because the information is already present it `TData` when combining with `TNode.directiveStart` and `TNode.directiveEnd`

Mainly this is true (conceptually):
```
expect(tNode.directives).toEqual(
    tData.slice(
        tNode.directivesStart,
        tNode.directivesEnd - tNode.DirectivesStart -1
    )
);
```

The refactoring removes `TNode.directives` and adds `TNode.directiveStyling` as we still need to keep location in the directive in `TNode`
mhevery added a commit that referenced this pull request Feb 3, 2020
`TNode.directives` was introduced in #34938. Turns out that it is unnecessary because the information is already present it `TData` when combining with `TNode.directiveStart` and `TNode.directiveEnd`

Mainly this is true (conceptually):
```
expect(tNode.directives).toEqual(
    tData.slice(
        tNode.directivesStart,
        tNode.directivesEnd - tNode.DirectivesStart -1
    )
);
```

The refactoring removes `TNode.directives` and adds `TNode.directiveStyling` as we still need to keep location in the directive in `TNode`

PR Close #35050
mhevery added a commit that referenced this pull request Feb 3, 2020
`TNode.directives` was introduced in #34938. Turns out that it is unnecessary because the information is already present it `TData` when combining with `TNode.directiveStart` and `TNode.directiveEnd`

Mainly this is true (conceptually):
```
expect(tNode.directives).toEqual(
    tData.slice(
        tNode.directivesStart,
        tNode.directivesEnd - tNode.DirectivesStart -1
    )
);
```

The refactoring removes `TNode.directives` and adds `TNode.directiveStyling` as we still need to keep location in the directive in `TNode`

PR Close #35050
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants