Skip to content

Commit 9651a91

Browse files
committed
feat(jsx): improve aria attributes
1 parent 43ada45 commit 9651a91

File tree

2 files changed

+189
-87
lines changed

2 files changed

+189
-87
lines changed

packages/jsx/src/index.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,3 +877,25 @@ test(
877877
)
878878
}),
879879
)
880+
881+
test(
882+
'aria attributes',
883+
setup((ctx, h, hf, mount, parent) => {
884+
const testAttribute = (attr: string, value: unknown, expected: unknown) => {
885+
const props = {[attr]: value}
886+
const element = <div {...props}></div>
887+
888+
expect(element.hasAttribute(attr)).toBe(value != null)
889+
expect(element.getAttribute(attr)).toBe(expected)
890+
}
891+
892+
testAttribute('aria-checked', undefined, null)
893+
testAttribute('aria-checked', null, null)
894+
testAttribute('aria-checked', true, 'true')
895+
testAttribute('aria-checked', false, 'false')
896+
testAttribute('aria-checked', 'true', 'true')
897+
testAttribute('aria-checked', 'false', 'false')
898+
testAttribute('aria-colcount', 1, '1')
899+
testAttribute('aria-colcount', '1', '1')
900+
}),
901+
)

0 commit comments

Comments
 (0)