File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ private extension HTMLElement {
209209 switch returnType {
210210 case . boolean: return string. elementsEqual ( " true " ) ? " " : nil
211211 case . string, . enumCase:
212- if returnType == . string && string. isEmpty {
212+ if returnType == . string && string. isEmpty && key != " href " {
213213 return nil
214214 }
215215 string. escapeHTML ( escapeAttributes: true )
Original file line number Diff line number Diff line change @@ -95,6 +95,20 @@ extension HTMLKitTests {
9595 string = #html( xmlns: " test " )
9696 #expect( string == " <!DOCTYPE html><html xmlns= \" test \" ></html> " )
9797 }
98+ @Test func element_a( ) {
99+ var string : String = #a( " Test " )
100+ #expect( string == " <a>Test</a> " )
101+
102+ string = #a( href: " test " , " Test " )
103+ #expect( string == " <a href= \" test \" >Test</a> " )
104+
105+ string = #a( href: " " , " Test " )
106+ #expect( string == " <a href>Test</a> " )
107+
108+ let test : String = " test "
109+ string = #a( href: " \( test) " , " Test " )
110+ #expect( string == " <a href= \" test \" >Test</a> " )
111+ }
98112 @Test func element_area( ) {
99113 var string : StaticString = #area( coords: [ 1 , 2 , 3 ] )
100114 #expect( string == " <area coords= \" 1,2,3 \" > " )
You can’t perform that action at this time.
0 commit comments