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(NcIconSvgWrapper): remove new keepId prop #4609

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/components/NcIconSvgWrapper/NcIconSvgWrapper.vue
Expand Up @@ -119,16 +119,6 @@ export default {
type: String,
default: '',
},

/**
* By default MDI icons have an ID on the `<svg>` element. It leads to dupliated IDs on a web-page.
* This component removes the ID on the received SVG.
* Use this prop to disable this behavior and to not remove the ID.
*/
keepId: {
type: Boolean,
default: false,
},
},

computed: {
Expand All @@ -146,7 +136,7 @@ export default {
return ''
}

if (!this.keepId && svgDocument.documentElement.id) {
if (svgDocument.documentElement.id) {
svgDocument.documentElement.removeAttribute('id')
}

Expand Down
Expand Up @@ -41,12 +41,6 @@ describe('NcIconSvgWrapper', () => {
expect(svg.attributes('id')).not.toBeDefined()
})

it('should keep ID from rendered SVG when keepId is provided', () => {
const wrapper = mountNcIconSvgWrapper({ svg: SVG_ICON, keepId: true })
const svg = wrapper.get('svg')
expect(svg.attributes('id')).toBe('mdi-check')
})

it('should sanitize SVG', () => {
const svgWithXSS = `<svg xmlns="http://www.w3.org/2000/svg" id="mdi-check" viewBox="0 0 24 24">
<path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" />
Expand Down