Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(xml/parser): refactor element parsing #6557

Merged
merged 11 commits into from Dec 1, 2022
10 changes: 5 additions & 5 deletions crates/swc_html_parser/src/lexer/mod.rs
Expand Up @@ -1067,16 +1067,16 @@ where
State::TagOpen => {
// Consume the next input character:
match self.consume_next_char() {
// U+0021 EXCLAMATION MARK (!)
// Switch to the markup declaration open state.
Some('!') => {
self.state = State::MarkupDeclarationOpen;
}
// U+002F SOLIDUS (/)
// Switch to the end tag open state.
Some('/') => {
self.state = State::EndTagOpen;
}
// U+0021 EXCLAMATION MARK (!)
// Switch to the markup declaration open state.
Some('!') => {
self.state = State::MarkupDeclarationOpen;
}
// ASCII alpha
// Create a new start tag token, set its tag name to the empty string.
// Reconsume in the tag name state.
Expand Down
4 changes: 0 additions & 4 deletions crates/swc_xml_ast/src/token.rs
Expand Up @@ -40,10 +40,6 @@ pub enum Token {
tag_name: JsWord,
attributes: Vec<AttributeToken>,
},
ShortTag {
tag_name: JsWord,
attributes: Vec<AttributeToken>,
},
EmptyTag {
tag_name: JsWord,
attributes: Vec<AttributeToken>,
Expand Down
1 change: 0 additions & 1 deletion crates/swc_xml_codegen/src/lib.rs
Expand Up @@ -462,7 +462,6 @@ fn escape_string(value: &str, is_attribute_mode: bool) -> String {
'&' => {
result.push_str("&amp;");
}
'\u{00A0}' => result.push_str("&nbsp;"),
'"' if is_attribute_mode => result.push_str("&quot;"),
'<' if !is_attribute_mode => {
result.push_str("&lt;");
Expand Down
2 changes: 2 additions & 0 deletions crates/swc_xml_parser/src/error.rs
Expand Up @@ -80,6 +80,7 @@ impl Error {
ErrorKind::MissingWhitespaceBetweenDoctypePublicAndSystemIdentifiers => {
"Missing whitespace between doctype public and system identifiers".into()
}
ErrorKind::MissingEndTagName => "Missing end tag name".into(),
ErrorKind::NestedComment => "Nested comment".into(),
ErrorKind::DoubleHyphenWithInComment => "Double hyper within comment".into(),
ErrorKind::NoncharacterInInputStream => "Noncharacter in input stream".into(),
Expand Down Expand Up @@ -150,6 +151,7 @@ pub enum ErrorKind {
MissingWhitespaceAfterDoctypeSystemKeyword,
MissingWhitespaceBeforeDoctypeName,
MissingWhitespaceBetweenDoctypePublicAndSystemIdentifiers,
MissingEndTagName,
NestedComment,
DoubleHyphenWithInComment,
NoncharacterInInputStream,
Expand Down