fix(footer-nav-item): use firstElementChild #1502
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
using firstChild selects comment nodes and therefore gives a console error when adding a class to it
Description
There is a slight difference in where Angular renders the comment node (ie, the anchor for the view container) slightly differently in the @if(){}@else{} syntax compared to the
*ngIf(condition; else tpl)syntax.That is, in the @else part, the first child is now the comment node which isn't the case with the explicit structural directive syntax.
LgFooterNavItemComponentwants to get hold of theaelement orbuttonelement then add a css class to it,this.renderer.addClass(childEl, 'lg-footer-action');. The else part errors as the firstChild returns the comment node, and tries to add a class to the comment node .Using the
firstElementChildsolves this issue, as it will gets the first element and not the nodes (comments and text). firstChild gets the first comment, text or element.Fixes # (issue)
Requirements
Please briefly outline any requirements for the work which may aid the testing and review process.
Design link: (link to design or delete if not required)
Screenshot: (if appropriate provide a quick screen grab of the changes)
Checklist: