Skip to content
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

Merged
merged 2 commits into from Aug 2, 2017

Conversation

crisbeto
Copy link
Member

  • 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 #6093.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 28, 2017
svg => this._setSvgElement(svg),
(err: Error) => console.log(`Error retrieving icon: ${err.message}`));
}
if ((changes.svgIcon || changes.svgSrc) && this.svgIcon) {
Copy link
Member

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).


// 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) {
Copy link
Member

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


// 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) {
Copy link
Member

@jelbourn jelbourn Jul 28, 2017

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.

Copy link
Member Author

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.

@crisbeto
Copy link
Member Author

Addressed the feedback @jelbourn.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Jul 31, 2017
* 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.
@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 6, 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 PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

svgIcon with bound expression in contents fails for IE 11
4 participants