-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(icon): not taking current path after initialization #13641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
When resolving the current path while prefixing `url()` references, we use a provider to get the current path so we can account for server-side rendering and to be able to stub it out during tests. Since the provider is an object with a regular `pathname` property, the path will only be resolved once the first time an icon is resolved and then it'll be cached. This means that all subsequent icons will take an incorrect path. Related to angular#13628.
1ac9cd6
to
e18522d
Compare
const elementsWithFuncIri = element.querySelectorAll(funcIriAttributeSelector); | ||
const path = this._location.pathname ? this._location.pathname.split('#')[0] : ''; | ||
const elements = this._elementsWithExternalReferences = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just initialize _elementsWithExternalReferences
as an empty Map
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it so we can check for its presence in ngAfterViewChecked
, rather than having to check the size. I'm not sure whether I'm not micro-optimizing it though.
private _previousPath?: string; | ||
|
||
/** Keeps track of the elements and attributes that we've prefixed with the current path. */ | ||
private _elementsWithExternalReferences?: Map<Element, {name: string, value: string}[]>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you reuse this as cachedElements
in the ngAfterViewChecked
method so that its a shorter name, should we just use cachedElements
as the property name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that calling the property cachedElements
is a little too generic.
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. |
When resolving the current path while prefixing
url()
references, we use a provider to get the current path so we can account for server-side rendering and to be able to stub it out during tests. Since the provider is an object with a regularpathname
property, the path will only be resolved once the first time an icon is resolved and then it'll be cached. This means that all subsequent icons will take an incorrect path.Related to #13628.