Skip to content

Commit

Permalink
fix(svg): don't style width/height in attributes with unit (#5550)
Browse files Browse the repository at this point in the history
* fix(svg): don't style width/height in attributes with unit

Browsers warn for a width/height attribute which isn't a number, as it can only be a "unitless value" (px). Despite that it does seem to work.

Components involved:
- SearchBox in Vue
- Panel in JS
- Refresh in hooks example

* snapshot
  • Loading branch information
Haroenv committed Mar 16, 2023
1 parent 50344e3 commit 31b85a6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
6 changes: 4 additions & 2 deletions examples/react-hooks/default-theme/src/components/Refresh.tsx
Expand Up @@ -13,10 +13,12 @@ export function Refresh() {
}}
>
<svg
width="1rem"
height="1rem"
fill="none"
viewBox="0 0 24 24"
style={{
width: '1rem',
height: '1rem',
}}
stroke="currentColor"
strokeWidth={2}
>
Expand Down
3 changes: 1 addition & 2 deletions packages/instantsearch.js/src/widgets/panel/panel.tsx
Expand Up @@ -265,8 +265,7 @@ const panel: PanelWidget = (panelWidgetParams) => {
collapseButtonText: ({ collapsed: isCollapsed }) =>
`<svg
class="${cssClasses.collapseIcon}"
width="1em"
height="1em"
style="width: 1em; height: 1em;"
viewBox="0 0 500 500"
>
<path d="${
Expand Down
3 changes: 1 addition & 2 deletions packages/vue-instantsearch/src/components/SearchInput.vue
Expand Up @@ -68,8 +68,7 @@
aria-hidden="true"
role="img"
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
style="width: 1em; height: 1em"
viewBox="0 0 20 20"
:class="suit('resetIcon')"
>
Expand Down
Expand Up @@ -44,10 +44,9 @@ exports[`allows search bar classes override when it's searchable 1`] = `
>
<svg aria-hidden="true"
class="ais-SearchBox-resetIcon"
height="1em"
role="img"
style="width: 1em; height: 1em;"
viewbox="0 0 20 20"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M8.114 10L.944 2.83 0 1.885 1.886 0l.943.943L10 8.113l7.17-7.17.944-.943L20 1.886l-.943.943-7.17 7.17 7.17 7.17.943.944L18.114 20l-.943-.943-7.17-7.17-7.17 7.17-.944.943L0 18.114l.943-.943L8.113 10z"
Expand Down Expand Up @@ -304,10 +303,9 @@ exports[`renders correctly when it's searchable 1`] = `
>
<svg aria-hidden="true"
class="ais-SearchBox-resetIcon"
height="1em"
role="img"
style="width: 1em; height: 1em;"
viewbox="0 0 20 20"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M8.114 10L.944 2.83 0 1.885 1.886 0l.943.943L10 8.113l7.17-7.17.944-.943L20 1.886l-.943.943-7.17 7.17 7.17 7.17.943.944L18.114 20l-.943-.943-7.17-7.17-7.17 7.17-.944.943L0 18.114l.943-.943L8.113 10z"
Expand Down
Expand Up @@ -43,10 +43,9 @@ exports[`renders HTML correctly 1`] = `
>
<svg aria-hidden="true"
class="ais-SearchBox-resetIcon"
height="1em"
role="img"
style="width: 1em; height: 1em;"
viewbox="0 0 20 20"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M8.114 10L.944 2.83 0 1.885 1.886 0l.943.943L10 8.113l7.17-7.17.944-.943L20 1.886l-.943.943-7.17 7.17 7.17 7.17.943.944L18.114 20l-.943-.943-7.17-7.17-7.17 7.17-.944.943L0 18.114l.943-.943L8.113 10z"
Expand Down
4 changes: 2 additions & 2 deletions specs/src/pages/widgets/panel.md
Expand Up @@ -16,7 +16,7 @@ althtml1: |
<div class="ais-Panel-header">
<span>Header</span>
<button class="ais-Panel-collapseButton" aria-expanded="true">
<svg class="ais-Panel-collapseIcon" width="1em" height="1em" viewBox="0 0 500 500">
<svg class="ais-Panel-collapseIcon" style="width: 1em; height: 1em" viewBox="0 0 500 500">
<path d="M250 400l150-300H100z" fill="currentColor" />
</svg>
</button>
Expand All @@ -30,7 +30,7 @@ althtml2: |
<div class="ais-Panel-header">
<span>Header</span>
<button class="ais-Panel-collapseButton" aria-expanded="false">
<svg class="ais-Panel-collapseIcon" width="1em" height="1em" viewBox="0 0 500 500">
<svg class="ais-Panel-collapseIcon" style="width: 1em; height: 1em" viewBox="0 0 500 500">
<path d="M100 250l300-150v300z" fill="currentColor" />
</svg>
</button>
Expand Down

0 comments on commit 31b85a6

Please sign in to comment.