Skip to content

Commit ba9cd1c

Browse files
committed
chore(compiler-vapor): add runtime test for attribute parsing behavior
1 parent 3e90f4e commit ba9cd1c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/runtime-vapor/__tests__/dom/template.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,25 @@ describe('api: template', () => {
4040
expect(nthChild(root, 2)).toBe(root.childNodes[2])
4141
expect(next(b)).toBe(root.childNodes[2])
4242
})
43+
44+
test('attribute quote omission', () => {
45+
{
46+
const t = template('<div id=foo class=bar alt=`<="foo></div>')
47+
const root = t() as HTMLElement
48+
49+
expect(root.attributes).toHaveLength(3)
50+
expect(root.getAttribute('id')).toBe('foo')
51+
expect(root.getAttribute('class')).toBe('bar')
52+
expect(root.getAttribute('alt')).toBe('`<="foo')
53+
}
54+
55+
{
56+
const t = template('<div id="foo>bar"class="has whitespace"></div>')
57+
const root = t() as HTMLElement
58+
59+
expect(root.attributes).toHaveLength(2)
60+
expect(root.getAttribute('id')).toBe('foo>bar')
61+
expect(root.getAttribute('class')).toBe('has whitespace')
62+
}
63+
})
4364
})

0 commit comments

Comments
 (0)