-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client): add key attribute to each nested element in runtime
To suppress react key warnings in runtime.
- Loading branch information
Showing
5 changed files
with
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { buildCreateChildrenFn } from './runtime' | ||
|
||
describe('buildCreateChildrenFn', () => { | ||
it('should set key for children', async () => { | ||
const createElement = vi.fn() | ||
const importComponent = vi.fn() | ||
const createChildren = buildCreateChildrenFn(createElement, importComponent) | ||
|
||
const div = document.createElement('div') | ||
div.innerHTML = '<span>test</span><div>test2</div>' | ||
const result = await createChildren(div.childNodes) | ||
expect(createElement).toHaveBeenNthCalledWith(1, 'SPAN', { | ||
children: ['test'], | ||
key: 1, | ||
}) | ||
expect(createElement).toHaveBeenNthCalledWith(2, 'DIV', { | ||
children: ['test2'], | ||
key: 2, | ||
}) | ||
}) | ||
}) |
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