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

Do not use xlink:href in svg icons #2787

Merged
merged 1 commit into from
Mar 13, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/javascript/alchemy_admin/components/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Icon extends HTMLElement {

render() {
const sizeClass = this.size ? ` icon--${this.size}` : ""
this.innerHTML = `<svg class="icon${sizeClass}"><use xlink:href="${this.spriteUrl}#ri-${this.iconName}${this.style}" /></svg>`
this.innerHTML = `<svg class="icon${sizeClass}"><use href="${this.spriteUrl}#ri-${this.iconName}${this.style}" /></svg>`
}

set name(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<% elsif navigation["inline_image"] %>
<%== navigation["inline_image"] %>
<% elsif navigation["icon"] %>
<%# Cannot use the render_icon helper, because the navigation["icon"] includes the style %>
<svg class="icon">
<use xlink:href="<%= asset_path("remixicon.symbol.svg") %>#ri-<%= navigation["icon"] %>" />
<use href="<%= asset_path("remixicon.symbol.svg") %>#ri-<%= navigation["icon"] %>" />
</svg>
<% else %>
<%= render_icon :table %>
Expand Down
8 changes: 4 additions & 4 deletions spec/javascript/alchemy_admin/components/icon.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("alchemy-icon", () => {
const icon = renderComponent("alchemy-icon", html)

expect(icon.innerHTML).toEqual(
'<svg class="icon"><use xlink:href="/assets/remixicon.symbol.svg#ri-image-line"></use></svg>'
'<svg class="icon"><use href="/assets/remixicon.symbol.svg#ri-image-line"></use></svg>'
)
})

Expand All @@ -22,7 +22,7 @@ describe("alchemy-icon", () => {
const icon = renderComponent("alchemy-icon", html)

expect(icon.innerHTML).toEqual(
'<svg class="icon"><use xlink:href="/assets/remixicon.symbol.svg#ri-image-fill"></use></svg>'
'<svg class="icon"><use href="/assets/remixicon.symbol.svg#ri-image-fill"></use></svg>'
)
})

Expand All @@ -34,7 +34,7 @@ describe("alchemy-icon", () => {
const icon = renderComponent("alchemy-icon", html)

expect(icon.innerHTML).toEqual(
'<svg class="icon"><use xlink:href="/assets/remixicon.symbol.svg#ri-image"></use></svg>'
'<svg class="icon"><use href="/assets/remixicon.symbol.svg#ri-image"></use></svg>'
)
})

Expand All @@ -46,7 +46,7 @@ describe("alchemy-icon", () => {
const icon = renderComponent("alchemy-icon", html)

expect(icon.innerHTML).toEqual(
'<svg class="icon icon--medium"><use xlink:href="/assets/remixicon.symbol.svg#ri-image-line"></use></svg>'
'<svg class="icon icon--medium"><use href="/assets/remixicon.symbol.svg#ri-image-line"></use></svg>'
)
})
})