Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

fix(icon): stop breaking id references when caching icon ids #11342

Merged
merged 2 commits into from Oct 23, 2018

Conversation

Splaktar
Copy link
Member

PR Checklist

Please check that your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added or this is not a bug fix / enhancement
  • Docs have been added, updated, or were not required

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Enhancement
[x] Documentation content changes
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

SVGs with embedded ids can be broken when they are read out of the icon cache.

Issue Number:
Fixes #8689

What is the new behavior?

SVGs with embedded ids can be read out of the icon cache without breaking because the id references are now updated in addition to the ids themselves.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Thanks to @ystreibel for starting this work in #11315!

@Splaktar Splaktar added type: bug type: docs needs: review This PR is waiting on review from the team P3: important Important issues that really should be fixed when possible. labels Jun 26, 2018
@Splaktar Splaktar added this to the 1.1.11 milestone Jun 26, 2018
@Splaktar Splaktar requested a review from jelbourn June 26, 2018 23:32
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@googlebot googlebot added the cla: no PR author needs to sign Google's CLA: https://opensource.google.com/docs/cla/ label Jun 26, 2018
src/components/icon/icon.spec.js Outdated Show resolved Hide resolved
src/components/icon/js/iconService.js Outdated Show resolved Hide resolved
src/components/icon/js/iconService.js Show resolved Hide resolved
src/components/icon/js/iconService.js Show resolved Hide resolved
@Splaktar Splaktar added in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs and removed needs: review This PR is waiting on review from the team labels Jun 26, 2018
@Splaktar Splaktar assigned Splaktar and unassigned josephperrott Jun 26, 2018
@ystreibel
Copy link

Hi everyone! You could use my commit for this PR!

@Splaktar Splaktar removed the cla: no PR author needs to sign Google's CLA: https://opensource.google.com/docs/cla/ label Jun 28, 2018
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 the cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ label Jun 28, 2018
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@googlebot googlebot added cla: no PR author needs to sign Google's CLA: https://opensource.google.com/docs/cla/ and removed cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ labels Jun 28, 2018
@Splaktar Splaktar added pr: merge ready This PR is ready for a caretaker to review pr: lgtm This PR has been approved by the reviewer and removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs labels Jun 28, 2018
@jelbourn jelbourn added the cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ label Jun 28, 2018
@josephperrott josephperrott added cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ and removed cla: no PR author needs to sign Google's CLA: https://opensource.google.com/docs/cla/ labels Oct 17, 2018
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

@josephperrott
Copy link
Member

Confirmed CLA manually.

@Splaktar Splaktar added Blocked Progress on this issue is blocked. Primarily used for PRs that are blocked by presubmit feedback. pr: presubmit-failures labels Oct 20, 2018
@Splaktar
Copy link
Member Author

This is causing 1 presubmit test failure that needs to be investigated and feedback provided so that a fix can be considered.

@Splaktar Splaktar removed Blocked Progress on this issue is blocked. Primarily used for PRs that are blocked by presubmit feedback. pr: presubmit-failures labels Oct 23, 2018
@Splaktar Splaktar assigned mmalerba and unassigned josephperrott Oct 23, 2018
@mmalerba mmalerba merged commit 841e8b2 into master Oct 23, 2018
@Splaktar Splaktar deleted the fixSvgIdMangling branch October 23, 2018 19:28
marosoft pushed a commit to marosoft/material that referenced this pull request Nov 11, 2018
…#11342)

<!-- 
Filling out this template is required! Do not delete it when submitting a Pull Request! Without this information, your Pull Request may be auto-closed.
-->
## PR Checklist
Please check that your PR fulfills the following requirements:
- [x] The commit message follows [our guidelines](https://github.com/angular/material/blob/master/.github/CONTRIBUTING.md#-commit-message-format)
- [x] Tests for the changes have been added or this is not a bug fix / enhancement
- [x] Docs have been added, updated, or were not required

## PR Type
What kind of change does this PR introduce?
<!-- Please check the one that applies to this PR using "x". -->
```
[x] Bugfix
[ ] Enhancement
[x] Documentation content changes
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Infrastructure changes
[ ] Other... Please describe:
```

## What is the current behavior?
SVGs with embedded `id`s can be broken when they are read out of the icon cache.

<!-- Please describe the current behavior that you are modifying and link to one or more relevant issues. -->
Issue Number: 
Fixes angular#8689

## What is the new behavior?
SVGs with embedded `id`s can be read out of the icon cache without breaking because the `id` references are now updated in addition to the `id`s themselves.

## Does this PR introduce a breaking change?
```
[ ] Yes
[x] No
```
<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->
<!-- Note that breaking changes are highly unlikely to get merged to master unless the validation is clear and the use case is critical. -->

## Other information
Thanks to @ystreibel for starting this work in angular#11315!
Splaktar added a commit that referenced this pull request Dec 17, 2018
innerHTML is not supported on svg or symbol elements in IE11
use XMLSerializer instead of innerHTML when innerHTML is not defined

Fixes #11543. Relates to #11342. Relates to #11162.
Splaktar added a commit that referenced this pull request Dec 20, 2018
innerHTML is not supported on svg or symbol elements in IE11
use XMLSerializer instead of innerHTML when innerHTML is not defined

Fixes #11543. Relates to #11342. Relates to #11162.
Splaktar added a commit that referenced this pull request Dec 20, 2018
innerHTML is not supported on svg or symbol elements in IE11
use XMLSerializer instead of innerHTML when innerHTML is not defined
add a test for empty SVGs to match a g3 test

Fixes #11543. Relates to #11342. Relates to #11162.
jelbourn pushed a commit that referenced this pull request Dec 20, 2018
innerHTML is not supported on svg or symbol elements in IE11
use XMLSerializer instead of innerHTML when innerHTML is not defined
add a test for empty SVGs to match a g3 test

Fixes #11543. Relates to #11342. Relates to #11162.
@Splaktar
Copy link
Member Author

It looks like our move to less verbose RegEx, in place of very verbose querySelectorAll strings, is causing a performance problem with large SVG files.

Splaktar added a commit that referenced this pull request Feb 25, 2019
use querySelectorAll as much as possible
reduce the use of RegEx on large chunks of DOM

Fixes #11651. Relates to #8689. Relates to #11342. Relates to #11635.
Splaktar added a commit that referenced this pull request Feb 25, 2019
use querySelectorAll as much as possible
reduce the use of RegEx on large chunks of DOM

Fixes #11651. Relates to #8689. Relates to #11342. Relates to #11635.
Splaktar added a commit that referenced this pull request Mar 1, 2019
use querySelectorAll as much as possible
reduce the use of RegEx on large chunks of DOM

Fixes #11651. Relates to #8689. Relates to #11342. Relates to #11635.
Splaktar added a commit that referenced this pull request Mar 1, 2019
use querySelectorAll as much as possible
reduce the use of RegEx on large chunks of DOM

Fixes #11651. Relates to #8689. Relates to #11342. Relates to #11635.
mmalerba pushed a commit that referenced this pull request Apr 4, 2019
<!-- 
Filling out this template is required! Do not delete it when submitting a Pull Request! Without this information, your Pull Request may be auto-closed.
-->
## PR Checklist
Please check that your PR fulfills the following requirements:
- [X] The commit message follows [our guidelines](https://github.com/angular/material/blob/master/.github/CONTRIBUTING.md#-commit-message-format)
- [X] Tests for the changes have been added or this is not a bug fix / enhancement
- [X] Docs have been added, updated, or were not required

## PR Type
What kind of change does this PR introduce?
<!-- Please check the one that applies to this PR using "x". -->
```
[X] Bugfix
[ ] Enhancement
[ ] Documentation content changes
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Infrastructure changes
[ ] Other... Please describe:
```

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying and link to one or more relevant issues. -->
When the same icon is used multiple times, they all have the same id.

Issue Number: 
Fixes #11395.
This fixes the issue found by @coennijhuis in PR #11342. 

## What is the new behavior?
When the same icon is used multiple times, they all have a different id. `_cache` followed by a number is appended to the id.

## Does this PR introduce a breaking change?
```
[ ] Yes
[X] No
```
<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->
<!-- Note that breaking changes are highly unlikely to get merged to master unless the validation is clear and the use case is critical. -->

## Other information
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ P3: important Important issues that really should be fixed when possible. pr: lgtm This PR has been approved by the reviewer pr: merge ready This PR is ready for a caretaker to review type: bug type: docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

svg-icon: id mangling on cache destroys xhref references
9 participants