diff --git a/crates/swc_html_ast/src/token.rs b/crates/swc_html_ast/src/token.rs index 95ecbfa5fdaa..048b48dcddcf 100644 --- a/crates/swc_html_ast/src/token.rs +++ b/crates/swc_html_ast/src/token.rs @@ -72,7 +72,7 @@ pub enum Token { #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] data: JsWord, #[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))] - raw: JsWord, + raw: Option, }, Character { value: char, diff --git a/crates/swc_html_parser/src/lexer/mod.rs b/crates/swc_html_parser/src/lexer/mod.rs index 6a1f4ba6760d..a28dbe6d849e 100644 --- a/crates/swc_html_parser/src/lexer/mod.rs +++ b/crates/swc_html_parser/src/lexer/mod.rs @@ -826,7 +826,7 @@ where self.emit_token(Token::Comment { data: comment.data.into(), - raw: comment.raw.into(), + raw: Some(comment.raw.into()), }); } diff --git a/crates/swc_html_parser/src/parser/mod.rs b/crates/swc_html_parser/src/parser/mod.rs index 6099d93a8e62..4293f8fa9607 100644 --- a/crates/swc_html_parser/src/parser/mod.rs +++ b/crates/swc_html_parser/src/parser/mod.rs @@ -8388,7 +8388,7 @@ where // node document is the same as that of the node in which the adjusted // insertion location finds itself. let (data, raw) = match &token_and_info.token { - Token::Comment { data, raw } => (data.clone(), Some(raw.clone())), + Token::Comment { data, raw } => (data.clone(), raw.clone()), _ => { unreachable!() } @@ -8407,7 +8407,7 @@ where token_and_info: &mut TokenAndInfo, ) -> PResult<()> { let (data, raw) = match &token_and_info.token { - Token::Comment { data, raw } => (data.clone(), Some(raw.clone())), + Token::Comment { data, raw } => (data.clone(), raw.clone()), _ => { unreachable!() } @@ -8427,7 +8427,7 @@ where token_and_info: &mut TokenAndInfo, ) -> PResult<()> { let (data, raw) = match &token_and_info.token { - Token::Comment { data, raw } => (data.clone(), Some(raw.clone())), + Token::Comment { data, raw } => (data.clone(), raw.clone()), _ => { unreachable!() } diff --git a/crates/swc_html_parser/tests/html5lib_tests.rs b/crates/swc_html_parser/tests/html5lib_tests.rs index c2078fc622d5..5adf076328be 100644 --- a/crates/swc_html_parser/tests/html5lib_tests.rs +++ b/crates/swc_html_parser/tests/html5lib_tests.rs @@ -2,7 +2,7 @@ use std::{fs, mem::take, path::PathBuf}; use common::{document_span_visualizer, DomVisualizer}; use serde_json::Value; -use swc_atoms::{js_word, JsWord}; +use swc_atoms::JsWord; use swc_common::{ collections::AHashSet, input::{SourceFileInput, StringInput}, @@ -210,7 +210,7 @@ fn html5lib_test_tokenizer(input: PathBuf) { *raw = None; } Token::Comment { ref mut raw, .. } => { - *raw = js_word!(""); + *raw = None; } _ => {} } @@ -355,7 +355,7 @@ fn html5lib_test_tokenizer(input: PathBuf) { vec![Token::Comment { data: data.into(), - raw: js_word!(""), + raw: None, }] } _ => {