Skip to content

fix(ivy): ensure parent/sub-class components evaluate styling correctly#29602

Closed
matsko wants to merge 3 commits intoangular:masterfrom
matsko:styling_queue
Closed

fix(ivy): ensure parent/sub-class components evaluate styling correctly#29602
matsko wants to merge 3 commits intoangular:masterfrom
matsko:styling_queue

Conversation

@matsko
Copy link
Contributor

@matsko matsko commented Mar 29, 2019

The new styling algorithm in angular is designed to evaluate host
bindings stylinh priority in order of directive evaluation order. This,
however, does not work with respect to parent/sub-class directives
because sub-class host bindings are run after the parent host bindings
but still have priority. This patch ensures that the host styling bindings
for parent and sub-class components/directives are executed with respect
to the styling algorithm prioritization.

Jira Issue: FW-1132

@ngbot ngbot bot added this to the needsTriage milestone Apr 1, 2019
@matsko matsko force-pushed the styling_queue branch 7 times, most recently from d02327b to 54dce63 Compare April 2, 2019 23:43
@matsko matsko requested a review from mhevery April 2, 2019 23:44
@matsko matsko marked this pull request as ready for review April 2, 2019 23:45
@matsko matsko requested a review from a team April 2, 2019 23:45
@matsko matsko requested a review from a team April 3, 2019 00:35
Copy link
Contributor

Choose a reason for hiding this comment

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

I think increment/decrement be in try-finally?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should incrementActiveHostDirectiveInheritanceDepth we merge incrementActiveHostDirectiveIndex since they are always called together?

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// since there can only one hostBindings function per root
// since there can only be one hostBindings function per root

Copy link
Contributor

Choose a reason for hiding this comment

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

Is activeHostContext needed? Seems like a left over from previous iteration.

Copy link
Contributor

Choose a reason for hiding this comment

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

if we reset depth to 0 here is decrementActiveHostDirectiveIndex method even needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need bothactiveHostDirectiveIndex and activeHostDirectiveInheritanceDepth they seem redundant.

Also I don't think activeHostDirectiveIndex is the right name. You are saying index which means it is index into something but than you just increment it. So it is more like uniqueId than on index?

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* A queue of all hostStyling* instructions.
* A queue of all hostStyling instructions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably add a comment that the queue is only used for the host?

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* a queue is contructed and then flushed once the styles are applied to
* a queue is constructed and then flushed once the styles are applied to

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* at a later point (instead of immediately such as how templater-level styling
* at a later point (instead of immediately such as how template-level styling

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* directives, are evluated at different points (depending on priority) and will therefore
* directives, are evaluated at different points (depending on priority) and will therefore

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Iterates throught the host instructions queue (if present within the provided
* Iterates through the host instructions queue (if present within the provided

@kara kara self-requested a review April 3, 2019 04:28
@matsko matsko requested a review from IgorMinar as a code owner April 3, 2019 18:14
@matsko matsko force-pushed the styling_queue branch 10 times, most recently from 5f8544e to 3293eb8 Compare April 4, 2019 00:07
@gkalpak gkalpak mentioned this pull request Apr 4, 2019
16 tasks
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.

@matsko I've left some comments (mostly about tests) that I would love to see addressed before this PR gets in (mostly nits so I hope it won't be too much trouble...). Thnx!

@matsko matsko force-pushed the styling_queue branch 3 times, most recently from 5f91e95 to 5051180 Compare April 5, 2019 17:27
The new styling algorithm in angular is designed to evaluate host
bindings stylinh priority in order of directive evaluation order. This,
however, does not work with respect to parent/sub-class directives
because sub-class host bindings are run after the parent host bindings
but still have priority. This patch ensures that the host styling bindings
for parent and sub-class components/directives are executed with respect
to the styling algorithm prioritization.

Jira Issue: FW-1132
@matsko
Copy link
Contributor Author

matsko commented Apr 5, 2019

@matsko matsko requested review from kara, mhevery and pkozlowski-opensource and removed request for IgorMinar April 5, 2019 19:47
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.

A few more small changes


let activeDirectiveId = MIN_DIRECTIVE_ID;
let activeDirectiveSuperClassDepthPosition = 0;
let activeDirectiveSuperClassHeight = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I can tell, this global has no docs. It's not clear to me why it's necessary (in addition to the depth). Can you add docs that explain why it's necessary?

const directiveIndex = getDirectiveIndexFromRegistry(context, directiveRef || null);

directiveIndex: number = 0): void {
assertValidDirectiveIndex(context, directiveIndex);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this should be an ngDevMode assert so it tree-shakes.

directiveRef: any, forceOverride?: boolean): void {
const directiveIndex = getDirectiveIndexFromRegistry(context, directiveRef || null);
directiveIndex: number, forceOverride?: boolean): void {
assertValidDirectiveIndex(context, directiveIndex);
Copy link
Contributor

@kara kara Apr 5, 2019

Choose a reason for hiding this comment

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

Needs devmode guard so it tree-shakes

@matsko matsko force-pushed the styling_queue branch 3 times, most recently from 50efa4e to a5155ab Compare April 5, 2019 21:56
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.

You'll probably need to re-run the symbol test now that assertValidDirectiveIndex should be tree shaken

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Total count of how many directives are apart of an inheritance chain.
* Total count of how many directives are a part of an inheritance chain.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* needs to keep track exactly how many were encountered so it can accurately
* needs to keep track of exactly how many were encountered so it can accurately

@matsko matsko added the action: merge The PR is ready for merge by the caretaker label Apr 5, 2019
@IgorMinar IgorMinar closed this in ec56354 Apr 5, 2019
wKoza pushed a commit to wKoza/angular that referenced this pull request Apr 17, 2019
…ly (angular#29602)

The new styling algorithm in angular is designed to evaluate host
bindings stylinh priority in order of directive evaluation order. This,
however, does not work with respect to parent/sub-class directives
because sub-class host bindings are run after the parent host bindings
but still have priority. This patch ensures that the host styling bindings
for parent and sub-class components/directives are executed with respect
to the styling algorithm prioritization.

Jira Issue: FW-1132

PR Close angular#29602
@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 Sep 14, 2019
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: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants