feat(html/ast): Add raw to comment tokens (#6202)

This commit is contained in:
Alexander Akait 2022-10-19 18:10:57 +03:00 committed by GitHub
parent 6008995db1
commit 99ea28674a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View File

@ -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<JsWord>,
},
Character {
value: char,

View File

@ -826,7 +826,7 @@ where
self.emit_token(Token::Comment {
data: comment.data.into(),
raw: comment.raw.into(),
raw: Some(comment.raw.into()),
});
}

View File

@ -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!()
}

View File

@ -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,
}]
}
_ => {