Initial Commit
This commit is contained in:
70
Sources/HRW/GenHTML/Elements/Optgroup.swift
Normal file
70
Sources/HRW/GenHTML/Elements/Optgroup.swift
Normal file
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// Optgroup.swift
|
||||
// HTMLStandard
|
||||
//
|
||||
// Generated on 09/23/2025.
|
||||
// THIS FILE IS GENERATED. DO NOT EDIT.
|
||||
//
|
||||
import Foundation
|
||||
|
||||
/// <optgroup> Group of options in a list box
|
||||
public class Optgroup : HTMLNode {
|
||||
|
||||
/// Whether the form control is disabled.
|
||||
public var disabled:Bool = false
|
||||
|
||||
/// User-visible label.
|
||||
public var label:String? = nil
|
||||
|
||||
|
||||
public init(_ attributes:[String:String], _ parser:XMLParser? = nil) throws {
|
||||
var globalAttr = GlobalAttributesBuilder()
|
||||
for (key, attValue) in attributes {
|
||||
switch (key) {
|
||||
case "disabled":
|
||||
disabled = true
|
||||
continue
|
||||
case "label":
|
||||
label = attValue
|
||||
continue
|
||||
|
||||
default: break
|
||||
}
|
||||
if globalAttr.trySetGlobalAttribute(key, attValue) {
|
||||
continue
|
||||
}
|
||||
throw AppError("Unexpected attribute: \(key)")
|
||||
}
|
||||
var allItems:[HTMLNode] = []
|
||||
while let obj = try parser?.readObject(endTag: "optgroup", xmlToHtmlMapper) {
|
||||
allItems.append(obj)
|
||||
}
|
||||
super.init(globalAttr, allItems)
|
||||
}
|
||||
|
||||
|
||||
public func addChild(_ someElement:IScriptSupporting) {
|
||||
children.append(someElement)
|
||||
}
|
||||
|
||||
public override func renderAttributes() -> String {
|
||||
var result = super.renderAttributes()
|
||||
if disabled {
|
||||
result += " disabled"
|
||||
}
|
||||
if let label = label {
|
||||
result += " label='\(label)'"
|
||||
}
|
||||
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
override var nodeName: String {
|
||||
return "optgroup"
|
||||
}
|
||||
|
||||
override var isVoidElement: Bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user