Skip to content

Commit ed25e09

Browse files
GiteaBotHesterGlunny
authored
Fix adding of empty class name (#23352) (#23360)
Backport #23352 This PR is to fix the error shown below. The reason is because [`class-name` prop](https://github.com/go-gitea/gitea/blob/main/web_src/js/components/ActionRunStatus.vue#L6) given to `svg` component has a space, and classList cannot add empty string. https://user-images.githubusercontent.com/17645053/223346720-c7f9de43-5e69-4ecf-93c0-90bf04090693.mov Co-authored-by: Hester Gong <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent 10df304 commit ed25e09

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

web_src/js/svg.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ export function svg(name, size = 16, className = '') {
8080
const svgNode = document.firstChild;
8181
if (size !== 16) svgNode.setAttribute('width', String(size));
8282
if (size !== 16) svgNode.setAttribute('height', String(size));
83-
if (className) svgNode.classList.add(...className.split(/\s+/));
83+
// filter array to remove empty string
84+
if (className) svgNode.classList.add(...className.split(/\s+/).filter(Boolean));
8485
return serializer.serializeToString(svgNode);
8586
}
8687

0 commit comments

Comments
 (0)