-
Notifications
You must be signed in to change notification settings - Fork 793
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly handle svg class attribute within
parseClassList
(#6085
) * fix: handle svg class whithin * add test --------- Co-authored-by: Dominique Wirz <[email protected]>
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// @ts-ignore may not be existing when project hasn't been built | ||
type HydrateModule = typeof import('../../hydrate'); | ||
let renderToString: HydrateModule['renderToString']; | ||
|
||
describe('custom svg element', function () { | ||
let originalConsoleError: typeof console.error; | ||
before(async () => { | ||
// @ts-ignore may not be existing when project hasn't been built | ||
const mod = await import('/hydrate/index.mjs'); | ||
renderToString = mod.renderToString; | ||
originalConsoleError = console.error; | ||
}); | ||
|
||
after(() => { | ||
console.error = originalConsoleError; | ||
}); | ||
|
||
it('should render without errors', async () => { | ||
const errorLogs: string[] = []; | ||
console.error = (message) => errorLogs.push(message); | ||
|
||
const { html } = await renderToString(`<custom-svg-element />`, { prettyHtml: true }); | ||
const stage = document.createElement('div'); | ||
stage.setAttribute('id', 'stage'); | ||
stage.setHTMLUnsafe(html); | ||
document.body.appendChild(stage); | ||
|
||
await expect($('custom-svg-element')).toHaveText(''); | ||
|
||
expect(errorLogs.length).toEqual(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, h } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'custom-svg-element', | ||
shadow: true, | ||
}) | ||
export class CustomSvgElement { | ||
render() { | ||
return ( | ||
<svg viewBox="0 0 54 54"> | ||
<circle cx="8" cy="18" width="54" height="8" r="2" /> | ||
</svg> | ||
); | ||
} | ||
} |