@@ -8,7 +8,7 @@ extension HTMLKitUtilities {
88 otherAttributes: [ String : String ] = [ : ]
99 ) -> ElementData {
1010 var context = context
11- return parseArguments ( context: & context)
11+ return parseArguments ( context: & context, otherAttributes : otherAttributes )
1212 }
1313
1414 public static func parseArguments(
@@ -20,44 +20,52 @@ extension HTMLKitUtilities {
2020 var innerHTML = [ Sendable] ( )
2121 var trailingSlash = false
2222 for element in context. arguments. children ( viewMode: . all) {
23- if let child = element. labeled {
24- context. key = " "
25- if let key = child. label? . text {
26- context. key = key
27- switch key {
28- case " encoding " :
29- context. encoding = parseEncoding ( expression: child. expression) ?? . string
30- case " representation " :
31- context. representation = parseRepresentation ( expr: child. expression) ?? . literalOptimized
32- case " lookupFiles " :
33- context. lookupFiles = Set ( child. expression. array!. elements. compactMap ( { $0. expression. stringLiteral? . string ( encoding: context. encoding) } ) )
34- case " attributes " :
35- ( globalAttributes, trailingSlash) = parseGlobalAttributes ( context: context, array: child. expression. array!. elements)
36- default :
37- context. key = otherAttributes [ key] ?? key
38- if let test = HTMLAttribute . Extra. parse ( context: context, expr: child. expression) {
39- attributes [ key] = test
40- } else if let literal = parseLiteralValue ( context: context, expr: child. expression) {
41- switch literal {
42- case . boolean( let b) : attributes [ key] = b
43- case . string, . interpolation, . interpolationDescribed:
44- attributes [ key] = literal. value ( key: key, escape: context. escape, escapeAttributes: context. escapeAttributes)
45- case . int( let i) : attributes [ key] = i
46- case . float( let f) : attributes [ key] = f
47- case . arrayOfLiterals( let literals) :
48- attributes [ key] = literals. compactMap ( { $0. value ( key: key, escape: context. escape, escapeAttributes: context. escapeAttributes) } ) . joined ( )
49- case . array:
50- switch literal. escapeArray ( ) {
51- case . array( let a) : attributes [ key] = a
52- default : break
53- }
23+ guard let child = element. labeled else { continue }
24+ context. key = " "
25+ if let key = child. label? . text {
26+ context. key = key
27+ switch key {
28+ case " encoding " :
29+ context. encoding = parseEncoding ( expression: child. expression) ?? . string
30+ case " representation " :
31+ context. representation = parseRepresentation ( expr: child. expression) ?? . literalOptimized
32+ case " lookupFiles " :
33+ if let elements = child. expression. array? . elements {
34+ context. lookupFiles = Set ( elements. compactMap ( { $0. expression. stringLiteral? . string ( encoding: context. encoding) } ) )
35+ }
36+ case " attributes " :
37+ if let elements = child. expression. array? . elements {
38+ ( globalAttributes, trailingSlash) = parseGlobalAttributes ( context: context, array: elements)
39+ }
40+ default :
41+ context. key = otherAttributes [ key] ?? key
42+ if let test = HTMLAttribute . Extra. parse ( context: context, expr: child. expression) {
43+ attributes [ key] = test
44+ } else if let literal = parseLiteral ( context: context, expr: child. expression) {
45+ switch literal {
46+ case . boolean( let b) :
47+ attributes [ key] = b
48+ case . string, . interpolation:
49+ attributes [ key] = literal. value ( key: key, escape: context. escape, escapeAttributes: context. escapeAttributes)
50+ case . int( let i) :
51+ attributes [ key] = i
52+ case . float( let f) :
53+ attributes [ key] = f
54+ case . arrayOfLiterals( let literals) :
55+ attributes [ key] = literals. compactMap ( { $0. value ( key: key, escape: context. escape, escapeAttributes: context. escapeAttributes) } ) . joined ( )
56+ case . array:
57+ switch literal. escapeArray ( ) {
58+ case . array( let a) :
59+ attributes [ key] = a
60+ default :
61+ break
5462 }
5563 }
5664 }
57- // inner html
58- } else if let inner_html = parseInnerHTML ( context: context, child: child) {
59- innerHTML. append ( inner_html)
6065 }
66+ // inner html
67+ } else if let inner_html = parseInnerHTML ( context: context, expr: child. expression) {
68+ innerHTML. append ( inner_html)
6169 }
6270 }
6371 if let statements = context. trailingClosure? . statements {
0 commit comments