@@ -21,14 +21,14 @@ extension HTMLElement {
2121 static func parse_element( node: some FreestandingMacroExpansionSyntax , context: some MacroExpansionContext ) -> String {
2222 let macroName : String = node. macroName. text
2323 let type : HTMLElementType = HTMLElementType ( rawValue: macroName) ?? HTMLElementType . a
24- let data : ElementData = parse_arguments ( arguments: node. arguments)
24+ let data : ElementData = parse_arguments ( elementType : type , arguments: node. arguments)
2525 var string : String = ( type == . html ? " <!DOCTYPE html> " : " " ) + " < " + type. rawValue + data. attributes + " > " + data. innerHTML
2626 if !type. isVoid {
2727 string += " </ " + type. rawValue + " > "
2828 }
2929 return " \" " + string + " \" "
3030 }
31- static func parse_arguments( arguments: LabeledExprListSyntax ) -> ElementData {
31+ static func parse_arguments( elementType : HTMLElementType , arguments: LabeledExprListSyntax ) -> ElementData {
3232 var attributes : [ String ] = [ ]
3333 var innerHTML : [ String ] = [ ]
3434 for element in arguments. children ( viewMode: . all) {
@@ -42,7 +42,7 @@ extension HTMLElement {
4242 innerHTML = parse_inner_html ( child: child)
4343 break
4444 default : // extra attribute
45- if let string: String = parse_extra_attribute ( child: child) {
45+ if let string: String = parse_extra_attribute ( elementType : elementType , child: child) {
4646 attributes. append ( string)
4747 }
4848 break
@@ -54,7 +54,7 @@ extension HTMLElement {
5454 }
5555 static func parse_element_macro( expression: MacroExpansionExprSyntax ) -> String {
5656 guard let elementType: HTMLElementType = HTMLElementType ( rawValue: expression. macroName. text) else { return " \( expression) " }
57- let data : ElementData = parse_arguments ( arguments: expression. arguments)
57+ let data : ElementData = parse_arguments ( elementType : elementType , arguments: expression. arguments)
5858 return " < " + elementType. rawValue + data. attributes + " > " + data. innerHTML + ( elementType. isVoid ? " " : " </ " + elementType. rawValue + " > " )
5959 }
6060 static func parse_inner_html( child: LabeledExprSyntax ) -> [ String ] {
@@ -170,7 +170,7 @@ private extension HTMLElement {
170170 return function. arguments. first!. expression. as ( ArrayExprSyntax . self) !. elements. map ( { $0. expression. as ( StringLiteralExprSyntax . self) !. string } )
171171 }
172172
173- static func parse_extra_attribute( child: LabeledExprSyntax ) -> String ? {
173+ static func parse_extra_attribute( elementType : HTMLElementType , child: LabeledExprSyntax ) -> String ? {
174174 let key : String = child. label!. text
175175 func yup( _ value: String ) -> String {
176176 return key + " = \\ \" " + value + " \\ \" "
@@ -183,7 +183,13 @@ private extension HTMLElement {
183183 return yup ( string)
184184 }
185185 if let member: String = expression. as ( MemberAccessExprSyntax . self) ? . declName. baseName. text {
186- return yup ( " \\ (HTMLElementAttribute. " + key[ key. startIndex] . uppercased ( ) + key[ key. index ( after: key. startIndex) ... ] + " . " + member + " ) " )
186+ let inner : String
187+ if elementType == . input && key == " type " {
188+ inner = " InputMode "
189+ } else {
190+ inner = key [ key. startIndex] . uppercased ( ) + key[ key. index ( after: key. startIndex) ... ]
191+ }
192+ return yup ( " \\ (HTMLElementAttribute. " + inner + " . " + member + " ) " )
187193 }
188194 if let _: NilLiteralExprSyntax = expression. as ( NilLiteralExprSyntax . self) {
189195 return nil
0 commit comments