-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: preserve id and class with g container
- Loading branch information
1 parent
11575c9
commit 58a9183
Showing
4 changed files
with
65 additions
and
3 deletions.
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
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,23 @@ | ||
import { it, describe, expect } from 'vitest' | ||
|
||
import { initFonts } from './utils.js' | ||
import satori from '../src/index.js' | ||
|
||
describe('Id and Class', () => { | ||
let fonts | ||
initFonts((f) => (fonts = f)) | ||
|
||
it('should preserve id and class attributes', async () => { | ||
const svg = await satori( | ||
<div id='test-element' className='class1 class2'></div>, | ||
{ | ||
width: 100, | ||
height: 100, | ||
fonts, | ||
} | ||
) | ||
expect(svg).toMatchInlineSnapshot( | ||
'"<svg width=\\"100\\" height=\\"100\\" viewBox=\\"0 0 100 100\\" xmlns=\\"http://www.w3.org/2000/svg\\"><g class=\\"class1 class2\\" id=\\"test-element\\"><mask id=\\"satori_om-id\\"><rect x=\\"0\\" y=\\"0\\" width=\\"0\\" height=\\"0\\" fill=\\"#fff\\"/></mask></g></svg>"' | ||
) | ||
}) | ||
}) |