@@ -15,3 +15,44 @@ test("attributes: filters invalid style keys", async () => {
1515 assert ( html . includes ( "color:red" ) )
1616 assert ( ! html . includes ( "invalid-key!" ) )
1717} )
18+
19+ test ( "attributes: accepts namespaced attributes with colons" , async ( ) => {
20+ const { template } = await compile ( __dirname )
21+ const html = template ( )
22+ // Test xml:lang namespace
23+ assert ( html . includes ( 'xml:lang="en"' ) , "Should include xml:lang attribute" )
24+ // Test xmlns:xlink namespace declaration
25+ assert (
26+ html . includes ( 'xmlns:xlink="http://www.w3.org/1999/xlink"' ) ,
27+ "Should include xmlns:xlink attribute" ,
28+ )
29+ // Test xlink:href attribute
30+ assert (
31+ html . includes ( 'xlink:href="#icon"' ) ,
32+ "Should include xlink:href attribute" ,
33+ )
34+ // Verify data attributes still work
35+ assert (
36+ html . includes ( 'data-test="value"' ) ,
37+ "Should include data-test attribute" ,
38+ )
39+ } )
40+
41+ test ( "attributes: filters out invalid characters while allowing colons" , async ( ) => {
42+ const { template } = await compile ( __dirname )
43+ const html = template ( )
44+ // Valid attributes with hyphens should be included
45+ assert (
46+ html . includes ( 'valid-attr="ok"' ) ,
47+ "Should include valid-attr attribute" ,
48+ )
49+ // Invalid attributes with @ and ! should be filtered
50+ assert (
51+ ! html . includes ( "invalid@attr" ) ,
52+ "Should not include attributes with @ character" ,
53+ )
54+ assert (
55+ ! html . includes ( "invalid!key" ) ,
56+ "Should not include attributes with ! character" ,
57+ )
58+ } )
0 commit comments