LibWeb: Add support for parsing comments in the Swift HTML tokenizer

This commit is contained in:
Andrew Kaster 2024-10-13 17:47:29 -06:00 committed by Andreas Kling
commit 9d0ce4df0f
Notes: github-actions[bot] 2024-10-16 06:32:37 +00:00
3 changed files with 273 additions and 0 deletions

View file

@ -141,6 +141,28 @@ public class HTMLToken {
}
}
}
public var selfClosing: Bool {
get {
switch self.type {
case .StartTag(_, let selfClosing, _, _):
return selfClosing
case .EndTag(_, let selfClosing, _, _):
return selfClosing
default:
preconditionFailure("selfClosing called on non-tag token")
}
}
set {
switch self.type {
case .StartTag(let tagName, _, let selfClosingAcknowledged, let attributes):
self.type = .StartTag(tagName: tagName, selfClosing: newValue, selfClosingAcknowledged: selfClosingAcknowledged, attributes: attributes)
case .EndTag(let tagName, _, let selfClosingAcknowledged, let attributes):
self.type = .EndTag(tagName: tagName, selfClosing: newValue, selfClosingAcknowledged: selfClosingAcknowledged, attributes: attributes)
default:
preconditionFailure("selfClosing= called on non-tag token")
}
}
}
public init() {}
public init(type: TokenType) {