-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix(icon): error when toggling icon with binding in IE11 #6102
Conversation
src/lib/icon/icon.ts
Outdated
svg => this._setSvgElement(svg), | ||
(err: Error) => console.log(`Error retrieving icon: ${err.message}`)); | ||
} | ||
if ((changes.svgIcon || changes.svgSrc) && this.svgIcon) { |
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.
The svgSrc
bits can go away; I removed support for svgSrc
a long time ago but apparently missed this spot (and also the class description).
src/lib/icon/icon.ts
Outdated
|
||
// Remove existing child nodes and add the new SVG element. Note that we can't | ||
// use innerHTML, because IE will throw if the element has a data binding. | ||
for (let child of layoutElement.childNodes) { |
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.
Can use const
in for of
src/lib/icon/icon.ts
Outdated
|
||
// Remove existing child nodes and add the new SVG element. Note that we can't | ||
// use innerHTML, because IE will throw if the element has a data binding. | ||
for (let child of layoutElement.childNodes) { |
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.
TypeScript will compile this to a for
loop that checks childNodes.length
on every iteration. I know that used to be something to avoid, but not sure if it's necessary any more.
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.
Hmm, I guess it makes sense for the browser to recompute it. I'll cache it in a variable.
451638f
to
56936a1
Compare
Addressed the feedback @jelbourn. |
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
* Fixes an error that was being logged by IE11 for icons that are toggled via `ngIf` and have a binding expression. * Some minor readability improvements in the icon component. Fixes angular#6093.
56936a1
to
bf1ff01
Compare
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. |
ngIf
and have a binding expression.Fixes #6093.