@@ -28,7 +28,7 @@ private extension HTMLElement {
2828 if key == " acceptCharset " {
2929 key = " accept-charset "
3030 }
31- if let string: String = parse_attribute ( elementType: elementType, key: key, expression: child. expression) {
31+ if let string: String = parse_attribute ( context : context , elementType: elementType, key: key, expression: child. expression) {
3232 attributes. append ( key + ( string. isEmpty ? " " : " = \\ \" " + string + " \\ \" " ) )
3333 }
3434 }
@@ -68,7 +68,7 @@ private extension HTMLElement {
6868 value = function. arguments. last!. expression. stringLiteral!. string
6969 break
7070 default :
71- if let string: String = parse_attribute ( elementType: elementType, key: key, expression: key_element) {
71+ if let string: String = parse_attribute ( context : context , elementType: elementType, key: key, expression: key_element) {
7272 value = string
7373 }
7474 break
@@ -128,17 +128,24 @@ private extension HTMLElement {
128128 }
129129 }
130130
131- static func parse_attribute( elementType: HTMLElementType , key: String , expression: ExprSyntax ) -> String ? {
131+ static func parse_attribute( context : some MacroExpansionContext , elementType: HTMLElementType , key: String , expression: ExprSyntax ) -> String ? {
132132 if let ( string, returnType) : ( String , LiteralReturnType ) = parse_literal_value ( elementType: elementType, key: key, expression: expression) {
133133 switch returnType {
134134 case . boolean: return string. elementsEqual ( " true " ) ? " " : nil
135135 case . string: return string
136136 case . interpolation: return " \\ ( " + string + " ) "
137137 }
138138 }
139+ let separator : String = get_separator ( key: key)
140+ let string_return_logic : ( ExprSyntax , String ) -> String = {
141+ if $1. contains ( separator) {
142+ context. diagnose ( Diagnostic ( node: $0, message: ErrorDiagnostic ( id: " characterNotAllowedInDeclaration " , message: " Character \" " + separator + " \" is not allowed when declaring values for \" " + key + " \" . " ) ) )
143+ }
144+ return $1
145+ }
139146 if let value: String = expression. array? . elements. compactMap ( {
140147 if let string: String = $0. expression. stringLiteral? . string {
141- return string
148+ return string_return_logic ( $0 . expression , string)
142149 }
143150 if let string: String = $0. expression. integerLiteral? . literal. text {
144151 return string
@@ -147,7 +154,7 @@ private extension HTMLElement {
147154 return HTMLElementAttribute . Extra. htmlValue ( enumName: enumName ( elementType: elementType, key: key) , for: string)
148155 }
149156 return nil
150- } ) . joined ( separator: get_separator ( key : key ) ) {
157+ } ) . joined ( separator: separator ) {
151158 return value
152159 }
153160 func member( _ value: String ) -> String {
0 commit comments