diff --git a/crates/swc_html_ast/src/base.rs b/crates/swc_html_ast/src/base.rs index 6e12c0be2b1..b3d1b9f7b1e 100644 --- a/crates/swc_html_ast/src/base.rs +++ b/crates/swc_html_ast/src/base.rs @@ -94,6 +94,7 @@ pub struct Attribute { pub struct Text { pub span: Span, pub data: JsWord, + pub raw: Option, } #[ast_node("Comment")] diff --git a/crates/swc_html_codegen/tests/fixture.rs b/crates/swc_html_codegen/tests/fixture.rs index 30f35e52e07..591acdaa09e 100644 --- a/crates/swc_html_codegen/tests/fixture.rs +++ b/crates/swc_html_codegen/tests/fixture.rs @@ -326,6 +326,12 @@ fn verify_document_fragment( struct DropSpan; impl VisitMut for DropSpan { + fn visit_mut_text(&mut self, n: &mut Text) { + n.visit_mut_children_with(self); + + n.raw = None; + } + fn visit_mut_element(&mut self, n: &mut Element) { n.visit_mut_children_with(self); diff --git a/crates/swc_html_parser/src/lexer/mod.rs b/crates/swc_html_parser/src/lexer/mod.rs index 334082d06d4..e2ecdf11a3e 100644 --- a/crates/swc_html_parser/src/lexer/mod.rs +++ b/crates/swc_html_parser/src/lexer/mod.rs @@ -362,12 +362,12 @@ where for c in self.temporary_buffer.clone().chars() { self.emit_token(Token::Character { value: c, - raw: Some(c.to_string().into()), + raw: Some(String::from(c).into()), }); } } - fn flush_code_points_consumed_as_character_reference(&mut self, _raw: Option) { + fn flush_code_points_consumed_as_character_reference(&mut self, raw: Option) { if self.is_consumed_as_part_of_an_attribute() { if let Some(Tag { attributes, .. }) = &mut self.current_tag_token { if let Some(attribute) = attributes.last_mut() { @@ -395,12 +395,27 @@ where } } } else { - for c in self.temporary_buffer.clone().chars() { - let raw = c.to_string(); + // When the length of raw is more than the length of temporary buffer we emit a + // raw character in the first character token + let mut once_raw = raw; + let mut once_emitted = false; + for c in self.temporary_buffer.clone().chars() { self.emit_token(Token::Character { value: c, - raw: Some(raw.into()), + raw: match once_raw { + Some(_) => { + once_emitted = true; + once_raw.take().map(|x| x.into()) + } + _ => { + if once_emitted { + None + } else { + Some(String::from(c).into()) + } + } + }, }); } } @@ -790,21 +805,21 @@ where self.emit_token(Token::Character { value: '\n', - raw: None, + raw: Some(raw.into()), }); } else { self.emit_token(Token::Character { value: c, - raw: None, + raw: Some(String::from(c).into()), }); }; } #[inline(always)] - fn emit_character_token(&mut self, value: (char, Option)) { + fn emit_character_token(&mut self, value: (char, char)) { self.emit_token(Token::Character { value: value.0, - raw: None, + raw: Some(String::from(value.1).into()), }); } @@ -854,7 +869,7 @@ where // character as a character token. Some(c @ '\x00') => { self.emit_error(ErrorKind::UnexpectedNullCharacter); - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // EOF // Emit an end-of-file token. @@ -892,7 +907,7 @@ where // REPLACEMENT CHARACTER character token. Some(c @ '\x00') => { self.emit_error(ErrorKind::UnexpectedNullCharacter); - self.emit_character_token((REPLACEMENT_CHARACTER, Some(c))); + self.emit_character_token((REPLACEMENT_CHARACTER, c)); } // EOF // Emit an end-of-file token. @@ -921,7 +936,7 @@ where // REPLACEMENT CHARACTER character token. Some(c @ '\x00') => { self.emit_error(ErrorKind::UnexpectedNullCharacter); - self.emit_character_token((REPLACEMENT_CHARACTER, Some(c))); + self.emit_character_token((REPLACEMENT_CHARACTER, c)); } // EOF // Emit an end-of-file token. @@ -950,7 +965,7 @@ where // REPLACEMENT CHARACTER character token. Some(c @ '\x00') => { self.emit_error(ErrorKind::UnexpectedNullCharacter); - self.emit_character_token((REPLACEMENT_CHARACTER, Some(c))); + self.emit_character_token((REPLACEMENT_CHARACTER, c)); } // EOF // Emit an end-of-file token. @@ -976,7 +991,7 @@ where // REPLACEMENT CHARACTER character token. Some(c @ '\x00') => { self.emit_error(ErrorKind::UnexpectedNullCharacter); - self.emit_character_token((REPLACEMENT_CHARACTER, Some(c))); + self.emit_character_token((REPLACEMENT_CHARACTER, c)); } // EOF // Emit an end-of-file token. @@ -1028,7 +1043,7 @@ where // character token and an end-of-file token. None => { self.emit_error(ErrorKind::EofBeforeTagName); - self.emit_character_token(('<', None)); + self.emit_character_token(('<', '<')); self.emit_token(Token::Eof); return Ok(()); @@ -1038,7 +1053,7 @@ where // LESS-THAN SIGN character token. Reconsume in the data state. _ => { self.emit_error(ErrorKind::InvalidFirstCharacterOfTagName); - self.emit_character_token(('<', None)); + self.emit_character_token(('<', '<')); self.reconsume_in_state(State::Data); } } @@ -1066,8 +1081,8 @@ where // token. None => { self.emit_error(ErrorKind::EofBeforeTagName); - self.emit_character_token(('<', None)); - self.emit_character_token(('/', None)); + self.emit_character_token(('<', '<')); + self.emit_character_token(('/', '/')); self.emit_token(Token::Eof); return Ok(()); @@ -1151,7 +1166,7 @@ where // Emit a U+003C LESS-THAN SIGN character token. Reconsume in the RCDATA // state. _ => { - self.emit_character_token(('<', None)); + self.emit_character_token(('<', '<')); self.reconsume_in_state(State::Rcdata); } } @@ -1171,8 +1186,8 @@ where // Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS // character token. Reconsume in the RCDATA state. _ => { - self.emit_character_token(('<', None)); - self.emit_character_token(('/', None)); + self.emit_character_token(('<', '<')); + self.emit_character_token(('/', '/')); self.reconsume_in_state(State::Rcdata); } } @@ -1180,8 +1195,8 @@ where // https://html.spec.whatwg.org/multipage/parsing.html#rcdata-end-tag-name-state State::RcdataEndTagName => { let anything_else = |lexer: &mut Lexer| { - lexer.emit_character_token(('<', None)); - lexer.emit_character_token(('/', None)); + lexer.emit_character_token(('<', '<')); + lexer.emit_character_token(('/', '/')); lexer.emit_temporary_buffer_as_character_tokens(); lexer.reconsume_in_state(State::Rcdata); }; @@ -1267,7 +1282,7 @@ where // Emit a U+003C LESS-THAN SIGN character token. Reconsume in the RAWTEXT // state. _ => { - self.emit_character_token(('<', None)); + self.emit_character_token(('<', '<')); self.reconsume_in_state(State::Rawtext); } } @@ -1287,8 +1302,8 @@ where // Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS // character token. Reconsume in the RAWTEXT state. _ => { - self.emit_character_token(('<', None)); - self.emit_character_token(('/', None)); + self.emit_character_token(('<', '<')); + self.emit_character_token(('/', '/')); self.reconsume_in_state(State::Rawtext); } } @@ -1296,8 +1311,8 @@ where // https://html.spec.whatwg.org/multipage/parsing.html#rawtext-end-tag-name-state State::RawtextEndTagName => { let anything_else = |lexer: &mut Lexer| { - lexer.emit_character_token(('<', None)); - lexer.emit_character_token(('/', None)); + lexer.emit_character_token(('<', '<')); + lexer.emit_character_token(('/', '/')); lexer.emit_temporary_buffer_as_character_tokens(); lexer.reconsume_in_state(State::Rawtext); }; @@ -1384,14 +1399,14 @@ where // SIGN character token and a U+0021 EXCLAMATION MARK character token. Some('!') => { self.state = State::ScriptDataEscapeStart; - self.emit_character_token(('<', None)); - self.emit_character_token(('!', None)); + self.emit_character_token(('<', '<')); + self.emit_character_token(('!', '!')); } // Anything else // Emit a U+003C LESS-THAN SIGN character token. Reconsume in the script // data state. _ => { - self.emit_character_token(('<', None)); + self.emit_character_token(('<', '<')); self.reconsume_in_state(State::ScriptData); } } @@ -1411,8 +1426,8 @@ where // Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS // character token. Reconsume in the script data state. _ => { - self.emit_character_token(('<', None)); - self.emit_character_token(('/', None)); + self.emit_character_token(('<', '<')); + self.emit_character_token(('/', '/')); self.reconsume_in_state(State::ScriptData); } } @@ -1420,8 +1435,8 @@ where // https://html.spec.whatwg.org/multipage/parsing.html#script-data-end-tag-name-state State::ScriptDataEndTagName => { let anything_else = |lexer: &mut Lexer| { - lexer.emit_character_token(('<', None)); - lexer.emit_character_token(('/', None)); + lexer.emit_character_token(('<', '<')); + lexer.emit_character_token(('/', '/')); lexer.emit_temporary_buffer_as_character_tokens(); lexer.reconsume_in_state(State::ScriptData); }; @@ -1501,7 +1516,7 @@ where // HYPHEN-MINUS character token. Some(c @ '-') => { self.state = State::ScriptDataEscapeStartDash; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // Anything else // Reconsume in the script data state. @@ -1519,7 +1534,7 @@ where // HYPHEN-MINUS character token. Some(c @ '-') => { self.state = State::ScriptDataEscapedDashDash; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // Anything else // Reconsume in the script data state. @@ -1537,7 +1552,7 @@ where // character token. Some(c @ '-') => { self.state = State::ScriptDataEscapedDash; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // U+003C LESS-THAN SIGN (<) // Switch to the script data escaped less-than sign state. @@ -1549,7 +1564,7 @@ where // REPLACEMENT CHARACTER character token. Some(c @ '\x00') => { self.emit_error(ErrorKind::UnexpectedNullCharacter); - self.emit_character_token((REPLACEMENT_CHARACTER, Some(c))); + self.emit_character_token((REPLACEMENT_CHARACTER, c)); } // EOF // This is an eof-in-script-html-comment-like-text parse error. Emit an @@ -1577,7 +1592,7 @@ where // HYPHEN-MINUS character token. Some(c @ '-') => { self.state = State::ScriptDataEscapedDashDash; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // U+003C LESS-THAN SIGN (<) // Switch to the script data escaped less-than sign state. @@ -1590,7 +1605,7 @@ where Some(c @ '\x00') => { self.emit_error(ErrorKind::UnexpectedNullCharacter); self.state = State::ScriptDataEscaped; - self.emit_character_token((REPLACEMENT_CHARACTER, Some(c))); + self.emit_character_token((REPLACEMENT_CHARACTER, c)); } // EOF // This is an eof-in-script-html-comment-like-text parse error. Emit an @@ -1618,7 +1633,7 @@ where // U+002D HYPHEN-MINUS (-) // Emit a U+002D HYPHEN-MINUS character token. Some(c @ '-') => { - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // U+003C LESS-THAN SIGN (<) // Switch to the script data escaped less-than sign state. @@ -1630,7 +1645,7 @@ where // character token. Some(c @ '>') => { self.state = State::ScriptData; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // U+0000 NULL // This is an unexpected-null-character parse error. Switch to the script @@ -1638,7 +1653,7 @@ where Some(c @ '\x00') => { self.emit_error(ErrorKind::UnexpectedNullCharacter); self.state = State::ScriptDataEscaped; - self.emit_character_token((REPLACEMENT_CHARACTER, Some(c))); + self.emit_character_token((REPLACEMENT_CHARACTER, c)); } // EOF // This is an eof-in-script-html-comment-like-text parse error. Emit an @@ -1676,14 +1691,14 @@ where // state. Some(c) if is_ascii_alpha(c) => { self.temporary_buffer.clear(); - self.emit_character_token(('<', None)); + self.emit_character_token(('<', '<')); self.reconsume_in_state(State::ScriptDataDoubleEscapeStart); } // Anything else // Emit a U+003C LESS-THAN SIGN character token. Reconsume in the script // data escaped state. _ => { - self.emit_character_token(('<', None)); + self.emit_character_token(('<', '<')); self.reconsume_in_state(State::ScriptDataEscaped); } } @@ -1703,8 +1718,8 @@ where // Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS // character token. Reconsume in the script data escaped state. _ => { - self.emit_character_token(('<', None)); - self.emit_character_token(('/', None)); + self.emit_character_token(('<', '<')); + self.emit_character_token(('/', '/')); self.reconsume_in_state(State::ScriptDataEscaped); } } @@ -1712,8 +1727,8 @@ where // https://html.spec.whatwg.org/multipage/parsing.html#script-data-escaped-end-tag-name-state State::ScriptDataEscapedEndTagName => { let anything_else = |lexer: &mut Lexer| { - lexer.emit_character_token(('<', None)); - lexer.emit_character_token(('/', None)); + lexer.emit_character_token(('<', '<')); + lexer.emit_character_token(('/', '/')); lexer.emit_temporary_buffer_as_character_tokens(); lexer.reconsume_in_state(State::ScriptDataEscaped); }; @@ -1818,7 +1833,7 @@ where self.state = State::ScriptDataEscaped; } - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // ASCII upper alpha // Append the lowercase version of the current input character (add 0x0020 @@ -1826,14 +1841,14 @@ where // input character as a character token. Some(c) if is_ascii_upper_alpha(c) => { self.temporary_buffer.push(c.to_ascii_lowercase()); - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // ASCII lower alpha // Append the current input character to the temporary buffer. Emit the // current input character as a character token. Some(c) if is_ascii_lower_alpha(c) => { self.temporary_buffer.push(c); - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // Anything else // Reconsume in the script data escaped state. @@ -1851,21 +1866,21 @@ where // HYPHEN-MINUS character token. Some(c @ '-') => { self.state = State::ScriptDataDoubleEscapedDash; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // U+003C LESS-THAN SIGN (<) // Switch to the script data double escaped less-than sign state. Emit a // U+003C LESS-THAN SIGN character token. Some(c @ '<') => { self.state = State::ScriptDataDoubleEscapedLessThanSign; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // U+0000 NULL // This is an unexpected-null-character parse error. Emit a U+FFFD // REPLACEMENT CHARACTER character token. Some(c @ '\x00') => { self.emit_error(ErrorKind::UnexpectedNullCharacter); - self.emit_character_token((REPLACEMENT_CHARACTER, Some(c))); + self.emit_character_token((REPLACEMENT_CHARACTER, c)); } // EOF // This is an eof-in-script-html-comment-like-text parse error. Emit an @@ -1893,14 +1908,14 @@ where // HYPHEN-MINUS character token. Some(c @ '-') => { self.state = State::ScriptDataDoubleEscapedDashDash; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // U+003C LESS-THAN SIGN (<) // Switch to the script data double escaped less-than sign state. Emit a // U+003C LESS-THAN SIGN character token. Some(c @ '<') => { self.state = State::ScriptDataDoubleEscapedLessThanSign; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // U+0000 NULL // This is an unexpected-null-character parse error. Switch to the script @@ -1909,7 +1924,7 @@ where Some(c @ '\x00') => { self.emit_error(ErrorKind::UnexpectedNullCharacter); self.state = State::ScriptDataDoubleEscaped; - self.emit_character_token((REPLACEMENT_CHARACTER, Some(c))); + self.emit_character_token((REPLACEMENT_CHARACTER, c)); } // EOF // This is an eof-in-script-html-comment-like-text parse error. Emit an @@ -1937,21 +1952,21 @@ where // U+002D HYPHEN-MINUS (-) // Emit a U+002D HYPHEN-MINUS character token. Some(c @ '-') => { - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // U+003C LESS-THAN SIGN (<) // Switch to the script data double escaped less-than sign state. Emit a // U+003C LESS-THAN SIGN character token. Some(c @ '<') => { self.state = State::ScriptDataDoubleEscapedLessThanSign; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // U+003E GREATER-THAN SIGN (>) // Switch to the script data state. Emit a U+003E GREATER-THAN SIGN // character token. Some(c @ '>') => { self.state = State::ScriptData; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // U+0000 NULL // This is an unexpected-null-character parse error. Switch to the script @@ -1960,7 +1975,7 @@ where Some(c @ '\x00') => { self.emit_error(ErrorKind::UnexpectedNullCharacter); self.state = State::ScriptDataDoubleEscaped; - self.emit_character_token((REPLACEMENT_CHARACTER, Some(c))); + self.emit_character_token((REPLACEMENT_CHARACTER, c)); } // EOF // This is an eof-in-script-html-comment-like-text parse error. Emit an @@ -1991,7 +2006,7 @@ where Some(c @ '/') => { self.temporary_buffer.clear(); self.state = State::ScriptDataDoubleEscapeEnd; - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // Anything else // Reconsume in the script data double escaped state. @@ -2033,7 +2048,7 @@ where self.state = State::ScriptDataDoubleEscaped; } - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // ASCII upper alpha // Append the lowercase version of the current input character (add 0x0020 @@ -2041,7 +2056,7 @@ where // input character as a character token. Some(c) if is_ascii_upper_alpha(c) => { self.temporary_buffer.push(c.to_ascii_lowercase()); - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // ASCII lower alpha // Append the current input character to the temporary buffer. Emit the @@ -2049,7 +2064,7 @@ where Some(c) if is_ascii_lower_alpha(c) => { self.temporary_buffer.push(c); - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } // Anything else // Reconsume in the script data double escaped state. @@ -3928,7 +3943,7 @@ where // Emit a U+005D RIGHT SQUARE BRACKET character token. Reconsume in the // CDATA section state. _ => { - self.emit_character_token((']', None)); + self.emit_character_token((']', ']')); self.reconsume_in_state(State::CdataSection); } } @@ -3940,7 +3955,7 @@ where // U+005D RIGHT SQUARE BRACKET (]) // Emit a U+005D RIGHT SQUARE BRACKET character token. Some(c @ ']') => { - self.emit_character_token((']', Some(c))); + self.emit_character_token((']', c)); } // U+003E GREATER-THAN SIGN character // Switch to the data state. @@ -3951,8 +3966,8 @@ where // Emit two U+005D RIGHT SQUARE BRACKET character tokens. Reconsume in the // CDATA section state. _ => { - self.emit_character_token((']', None)); - self.emit_character_token((']', None)); + self.emit_character_token((']', ']')); + self.emit_character_token((']', ']')); self.reconsume_in_state(State::CdataSection); } } @@ -4108,7 +4123,7 @@ where if self.is_consumed_as_part_of_an_attribute() { self.append_to_attribute(None, Some((false, Some(c), Some(c)))); } else { - self.emit_character_token((c, Some(c))); + self.emit_character_token((c, c)); } } // U+003B SEMICOLON (;) @@ -4270,39 +4285,40 @@ where } // https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state State::NumericCharacterReferenceEnd => { - let (value, raw) = if let Some(chars) = self.character_reference_code.take() { - let mut raw = String::with_capacity(8); - let mut i: u32 = 0; - let mut overflowed = false; + let (value, raw_char_ref) = + if let Some(chars) = self.character_reference_code.take() { + let mut raw = String::with_capacity(8); + let mut i: u32 = 0; + let mut overflowed = false; - for (base, value, c) in chars.iter() { - if let Some(c) = c { - raw.push(*c); - } + for (base, value, c) in chars.iter() { + if let Some(c) = c { + raw.push(*c); + } - if !overflowed { - if let Some(result) = i.checked_mul(*base as u32) { - i = result; - - if let Some(result) = i.checked_add(*value) { + if !overflowed { + if let Some(result) = i.checked_mul(*base as u32) { i = result; + + if let Some(result) = i.checked_add(*value) { + i = result; + } else { + i = 0x110000; + + overflowed = true; + } } else { i = 0x110000; overflowed = true; } - } else { - i = 0x110000; - - overflowed = true; } } - } - (i, raw) - } else { - unreachable!(); - }; + (i, raw) + } else { + unreachable!(); + }; // Check the character reference code: let cr = match value { @@ -4415,6 +4431,18 @@ where // buffer. // Flush code points consumed as a character reference. // Switch to the return state. + let old_temporary_buffer = self.temporary_buffer.clone(); + + let mut raw = + String::with_capacity(old_temporary_buffer.len() + raw_char_ref.len() + 1); + + raw.push_str(&old_temporary_buffer); + raw.push_str(&raw_char_ref); + + if self.cur == Some(';') { + raw.push(';'); + } + self.temporary_buffer.clear(); let c = match char::from_u32(cr) { diff --git a/crates/swc_html_parser/src/parser/mod.rs b/crates/swc_html_parser/src/parser/mod.rs index 99ebc52b56c..b3b1e6ef4df 100644 --- a/crates/swc_html_parser/src/parser/mod.rs +++ b/crates/swc_html_parser/src/parser/mod.rs @@ -488,7 +488,7 @@ where } } } - Data::Text { data } => { + Data::Text { data, raw } => { let span = if let Some(end_span) = node.end_span.take() { swc_common::Span::new(start_span.lo(), end_span.hi(), Default::default()) } else { @@ -498,6 +498,7 @@ where Child::Text(Text { span, data: data.take().into(), + raw: Some(raw.take().into()), }) } Data::Comment { data } => Child::Comment(Comment { @@ -8189,10 +8190,21 @@ where let children = parent.children.borrow(); if let Some(last) = children.last() { - if let Data::Text { data } = &last.data { + if let Data::Text { + data, + raw: raw_data, + } = &last.data + { match &token_and_info.token { - Token::Character { value: c, .. } => { + Token::Character { + value: c, + raw: raw_c, + } => { data.borrow_mut().push(*c); + + if let Some(raw_c) = raw_c { + raw_data.borrow_mut().push_str(raw_c); + } } _ => { unreachable!(); @@ -8213,10 +8225,21 @@ where let children = parent.children.borrow(); if let Some(previous) = children.get(i - 1) { - if let Data::Text { data } = &previous.data { + if let Data::Text { + data, + raw: raw_data, + } = &previous.data + { match &token_and_info.token { - Token::Character { value: c, .. } => { + Token::Character { + value: c, + raw: raw_c, + } => { data.borrow_mut().push(*c); + + if let Some(raw_c) = raw_c { + raw_data.borrow_mut().push_str(raw_c); + } } _ => { unreachable!(); @@ -8239,23 +8262,29 @@ where // is the same as that of the element in which the adjusted insertion location // finds itself, and insert the newly created node at the adjusted insertion // location. - let text = Node::new( - Data::Text { - data: match &token_and_info.token { - Token::Character { value: c, .. } => { - let mut data = String::with_capacity(255); + let (data, raw) = match &token_and_info.token { + Token::Character { + value: c, + raw: raw_c, + } => { + let mut data = String::with_capacity(255); - data.push(*c); + data.push(*c); - RefCell::new(data) - } - _ => { - unreachable!() - } - }, - }, - token_and_info.span, - ); + let mut raw = String::with_capacity(255); + + if let Some(raw_c) = raw_c { + raw.push_str(raw_c); + } + + (RefCell::new(data), RefCell::new(raw)) + } + _ => { + unreachable!() + } + }; + + let text = Node::new(Data::Text { data, raw }, token_and_info.span); self.insert_at_position(adjusted_insertion_location, text); diff --git a/crates/swc_html_parser/src/parser/node.rs b/crates/swc_html_parser/src/parser/node.rs index bd01bd5f524..9d865b4fd50 100644 --- a/crates/swc_html_parser/src/parser/node.rs +++ b/crates/swc_html_parser/src/parser/node.rs @@ -33,6 +33,7 @@ pub enum Data { }, Text { data: RefCell, + raw: RefCell, }, Comment { data: JsWord, diff --git a/crates/swc_html_parser/tests/fixture/attribute/basic/output.json b/crates/swc_html_parser/tests/fixture/attribute/basic/output.json index d31b95c7461..426d624607c 100644 --- a/crates/swc_html_parser/tests/fixture/attribute/basic/output.json +++ b/crates/swc_html_parser/tests/fixture/attribute/basic/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -80,7 +81,8 @@ "end": 60, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -93,7 +95,8 @@ "end": 69, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -106,7 +109,8 @@ "end": 77, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -126,7 +130,8 @@ "end": 85, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -582,7 +587,8 @@ "end": 165, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -615,7 +621,8 @@ "end": 209, "ctxt": 0 }, - "data": "x" + "data": "x", + "raw": "x" } ], "content": null, @@ -628,7 +635,8 @@ "end": 214, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -661,7 +669,8 @@ "end": 249, "ctxt": 0 }, - "data": "x" + "data": "x", + "raw": "x" } ], "content": null, @@ -674,7 +683,8 @@ "end": 254, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -722,7 +732,8 @@ "end": 300, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -782,7 +793,8 @@ "end": 336, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -818,7 +830,8 @@ "end": 398, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -854,7 +867,8 @@ "end": 417, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -902,7 +916,8 @@ "end": 455, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -938,7 +953,8 @@ "end": 499, "ctxt": 0 }, - "data": "\n\n\n\n" + "data": "\n\n\n\n", + "raw": "\n\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/attribute/class/output.json b/crates/swc_html_parser/tests/fixture/attribute/class/output.json index 85b03318cf0..5ab92f99429 100644 --- a/crates/swc_html_parser/tests/fixture/attribute/class/output.json +++ b/crates/swc_html_parser/tests/fixture/attribute/class/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -80,7 +81,8 @@ "end": 60, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -93,7 +95,8 @@ "end": 69, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -106,7 +109,8 @@ "end": 77, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -126,7 +130,8 @@ "end": 88, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -162,7 +167,8 @@ "end": 180, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -198,7 +204,8 @@ "end": 227, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -234,7 +241,8 @@ "end": 278, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -270,7 +278,8 @@ "end": 329, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -306,7 +315,8 @@ "end": 380, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -342,7 +352,8 @@ "end": 417, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -378,7 +389,8 @@ "end": 452, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -414,7 +426,8 @@ "end": 474, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -450,7 +463,8 @@ "end": 568, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -486,7 +500,8 @@ "end": 650, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -522,7 +537,8 @@ "end": 676, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -558,7 +574,8 @@ "end": 720, "ctxt": 0 }, - "data": "\n\n\n" + "data": "\n\n\n", + "raw": "\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/attribute/no-quotes/output.json b/crates/swc_html_parser/tests/fixture/attribute/no-quotes/output.json index 023f344d9c1..15341e571bf 100644 --- a/crates/swc_html_parser/tests/fixture/attribute/no-quotes/output.json +++ b/crates/swc_html_parser/tests/fixture/attribute/no-quotes/output.json @@ -61,7 +61,8 @@ "end": 32, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -94,7 +95,8 @@ "end": 80, "ctxt": 0 }, - "data": "This is a link" + "data": "This is a link", + "raw": "This is a link" } ], "content": null, @@ -107,7 +109,8 @@ "end": 102, "ctxt": 0 }, - "data": "\n\n\n\n" + "data": "\n\n\n\n", + "raw": "\n\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/attribute/quotes-in-meta/output.json b/crates/swc_html_parser/tests/fixture/attribute/quotes-in-meta/output.json index b3d82139ce3..bf7bedeab3c 100644 --- a/crates/swc_html_parser/tests/fixture/attribute/quotes-in-meta/output.json +++ b/crates/swc_html_parser/tests/fixture/attribute/quotes-in-meta/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -108,7 +109,8 @@ "end": 114, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -128,7 +130,8 @@ "end": 129, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -141,7 +144,8 @@ "end": 138, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -154,7 +158,8 @@ "end": 146, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -174,7 +179,8 @@ "end": 166, "ctxt": 0 }, - "data": "\ntest\n\n" + "data": "\ntest\n\n", + "raw": "\ntest\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/attribute/title/output.json b/crates/swc_html_parser/tests/fixture/attribute/title/output.json index 0712e42ddfb..692370ee5d5 100644 --- a/crates/swc_html_parser/tests/fixture/attribute/title/output.json +++ b/crates/swc_html_parser/tests/fixture/attribute/title/output.json @@ -61,7 +61,8 @@ "end": 32, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -94,7 +95,8 @@ "end": 76, "ctxt": 0 }, - "data": "The title Attribute" + "data": "The title Attribute", + "raw": "The title Attribute" } ], "content": null, @@ -107,7 +109,8 @@ "end": 83, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -140,7 +143,8 @@ "end": 179, "ctxt": 0 }, - "data": "Mouse over this paragraph, to display the title attribute as a tooltip." + "data": "Mouse over this paragraph, to display the title attribute as a tooltip.", + "raw": "Mouse over this paragraph, to display the title attribute as a tooltip." } ], "content": null, @@ -153,7 +157,8 @@ "end": 201, "ctxt": 0 }, - "data": "\n\n\n\n" + "data": "\n\n\n\n", + "raw": "\n\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/comment/after-body/output.json b/crates/swc_html_parser/tests/fixture/comment/after-body/output.json index a47378b15e3..0531af74cbe 100644 --- a/crates/swc_html_parser/tests/fixture/comment/after-body/output.json +++ b/crates/swc_html_parser/tests/fixture/comment/after-body/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -96,7 +97,8 @@ "end": 72, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -144,7 +146,8 @@ "end": 213, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -192,7 +195,8 @@ "end": 271, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -212,7 +216,8 @@ "end": 286, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -225,7 +230,8 @@ "end": 295, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -238,7 +244,8 @@ "end": 303, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -258,7 +265,8 @@ "end": 337, "ctxt": 0 }, - "data": "\nTest\n\n\n" + "data": "\nTest\n\n\n", + "raw": "\nTest\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/comment/basic-1/output.json b/crates/swc_html_parser/tests/fixture/comment/basic-1/output.json index 322c42df911..0266d20dd82 100644 --- a/crates/swc_html_parser/tests/fixture/comment/basic-1/output.json +++ b/crates/swc_html_parser/tests/fixture/comment/basic-1/output.json @@ -61,7 +61,8 @@ "end": 32, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Comment", @@ -79,7 +80,8 @@ "end": 57, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Comment", @@ -97,7 +99,8 @@ "end": 84, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -117,7 +120,8 @@ "end": 107, "ctxt": 0 }, - "data": "This is a paragraph." + "data": "This is a paragraph.", + "raw": "This is a paragraph." } ], "content": null, @@ -130,7 +134,8 @@ "end": 112, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Comment", @@ -148,7 +153,8 @@ "end": 184, "ctxt": 0 }, - "data": "\n\n\n \n\n\n" + "data": "\n\n\n \n\n\n", + "raw": "\n\n\n \n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/comment/basic/output.json b/crates/swc_html_parser/tests/fixture/comment/basic/output.json index dd4d3e49300..51d8e1089ad 100644 --- a/crates/swc_html_parser/tests/fixture/comment/basic/output.json +++ b/crates/swc_html_parser/tests/fixture/comment/basic/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -80,7 +81,8 @@ "end": 60, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -93,7 +95,8 @@ "end": 69, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -106,7 +109,8 @@ "end": 77, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -126,7 +130,8 @@ "end": 84, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Comment", @@ -144,7 +149,8 @@ "end": 99, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Comment", @@ -173,7 +179,8 @@ "end": 119, "ctxt": 0 }, - "data": "baz" + "data": "baz", + "raw": "baz" } ], "content": null, @@ -195,7 +202,8 @@ "end": 143, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -215,7 +223,8 @@ "end": 168, "ctxt": 0 }, - "data": "" + "data": "", + "raw": "" } ], "content": null, @@ -228,7 +237,8 @@ "end": 178, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -248,7 +258,8 @@ "end": 199, "ctxt": 0 }, - "data": "alert('')" + "data": "alert('')", + "raw": "alert('')" } ], "content": null, @@ -294,7 +307,8 @@ "end": 248, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -314,7 +328,8 @@ "end": 268, "ctxt": 0 }, - "data": "alert('-->')" + "data": "alert('-->')", + "raw": "alert('-->')" } ], "content": null, @@ -327,7 +342,8 @@ "end": 294, "ctxt": 0 }, - "data": "\n\n\n" + "data": "\n\n\n", + "raw": "\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/comment/ie-conditional/output.json b/crates/swc_html_parser/tests/fixture/comment/ie-conditional/output.json index 11047f6a1db..8c74d31ae61 100644 --- a/crates/swc_html_parser/tests/fixture/comment/ie-conditional/output.json +++ b/crates/swc_html_parser/tests/fixture/comment/ie-conditional/output.json @@ -61,7 +61,8 @@ "end": 32, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Comment", @@ -79,7 +80,8 @@ "end": 75, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Comment", @@ -97,7 +99,8 @@ "end": 118, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Comment", @@ -115,7 +118,8 @@ "end": 161, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Comment", @@ -133,7 +137,8 @@ "end": 204, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Comment", @@ -151,7 +156,8 @@ "end": 264, "ctxt": 0 }, - "data": "\n\n\n\n" + "data": "\n\n\n\n", + "raw": "\n\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/comment/multiline/output.json b/crates/swc_html_parser/tests/fixture/comment/multiline/output.json index b1a11acff95..0c27c73db1b 100644 --- a/crates/swc_html_parser/tests/fixture/comment/multiline/output.json +++ b/crates/swc_html_parser/tests/fixture/comment/multiline/output.json @@ -61,7 +61,8 @@ "end": 32, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -81,7 +82,8 @@ "end": 55, "ctxt": 0 }, - "data": "This is a paragraph." + "data": "This is a paragraph.", + "raw": "This is a paragraph." } ], "content": null, @@ -94,7 +96,8 @@ "end": 60, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Comment", @@ -112,7 +115,8 @@ "end": 152, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -132,7 +136,8 @@ "end": 179, "ctxt": 0 }, - "data": "This is a paragraph too." + "data": "This is a paragraph too.", + "raw": "This is a paragraph too." } ], "content": null, @@ -145,7 +150,8 @@ "end": 201, "ctxt": 0 }, - "data": "\n\n\n\n" + "data": "\n\n\n\n", + "raw": "\n\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/document/output.json b/crates/swc_html_parser/tests/fixture/document/output.json index 5f01c126c68..86981ec6a07 100644 --- a/crates/swc_html_parser/tests/fixture/document/output.json +++ b/crates/swc_html_parser/tests/fixture/document/output.json @@ -61,7 +61,8 @@ "end": 32, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -81,7 +82,8 @@ "end": 52, "ctxt": 0 }, - "data": "My First Heading" + "data": "My First Heading", + "raw": "My First Heading" } ], "content": null, @@ -94,7 +96,8 @@ "end": 59, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -114,7 +117,8 @@ "end": 81, "ctxt": 0 }, - "data": "My first paragraph." + "data": "My first paragraph.", + "raw": "My first paragraph." } ], "content": null, @@ -127,7 +131,8 @@ "end": 103, "ctxt": 0 }, - "data": "\n\n\n\n" + "data": "\n\n\n\n", + "raw": "\n\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/document_type/legacy/output.json b/crates/swc_html_parser/tests/fixture/document_type/legacy/output.json index 7e6de47e36a..9e7b0420b8e 100644 --- a/crates/swc_html_parser/tests/fixture/document_type/legacy/output.json +++ b/crates/swc_html_parser/tests/fixture/document_type/legacy/output.json @@ -60,7 +60,8 @@ "end": 74, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -96,7 +97,8 @@ "end": 101, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -144,7 +146,8 @@ "end": 242, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -192,7 +195,8 @@ "end": 300, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -212,7 +216,8 @@ "end": 315, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -225,7 +230,8 @@ "end": 324, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -238,7 +244,8 @@ "end": 332, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -258,7 +265,8 @@ "end": 360, "ctxt": 0 }, - "data": "\nTest\n\n\n" + "data": "\nTest\n\n\n", + "raw": "\nTest\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/document_type/lowercase/output.json b/crates/swc_html_parser/tests/fixture/document_type/lowercase/output.json index 103c8770736..f8abeb5bda2 100644 --- a/crates/swc_html_parser/tests/fixture/document_type/lowercase/output.json +++ b/crates/swc_html_parser/tests/fixture/document_type/lowercase/output.json @@ -47,7 +47,8 @@ "end": 35, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -67,7 +68,8 @@ "end": 63, "ctxt": 0 }, - "data": "Title of the document" + "data": "Title of the document", + "raw": "Title of the document" } ], "content": null, @@ -80,7 +82,8 @@ "end": 72, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -93,7 +96,8 @@ "end": 81, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -113,7 +117,8 @@ "end": 139, "ctxt": 0 }, - "data": "\nThe content of the document......\n\n\n\n" + "data": "\nThe content of the document......\n\n\n\n", + "raw": "\nThe content of the document......\n\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/document_type/uppercase/output.json b/crates/swc_html_parser/tests/fixture/document_type/uppercase/output.json index 103c8770736..f8abeb5bda2 100644 --- a/crates/swc_html_parser/tests/fixture/document_type/uppercase/output.json +++ b/crates/swc_html_parser/tests/fixture/document_type/uppercase/output.json @@ -47,7 +47,8 @@ "end": 35, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -67,7 +68,8 @@ "end": 63, "ctxt": 0 }, - "data": "Title of the document" + "data": "Title of the document", + "raw": "Title of the document" } ], "content": null, @@ -80,7 +82,8 @@ "end": 72, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -93,7 +96,8 @@ "end": 81, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -113,7 +117,8 @@ "end": 139, "ctxt": 0 }, - "data": "\nThe content of the document......\n\n\n\n" + "data": "\nThe content of the document......\n\n\n\n", + "raw": "\nThe content of the document......\n\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/element/a/output.json b/crates/swc_html_parser/tests/fixture/element/a/output.json index 5e77dcedaa2..22ca229c305 100644 --- a/crates/swc_html_parser/tests/fixture/element/a/output.json +++ b/crates/swc_html_parser/tests/fixture/element/a/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -80,7 +81,8 @@ "end": 60, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -93,7 +95,8 @@ "end": 69, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -106,7 +109,8 @@ "end": 77, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -126,7 +130,8 @@ "end": 85, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -159,7 +164,8 @@ "end": 120, "ctxt": 0 }, - "data": "First" + "data": "First", + "raw": "First" } ], "content": null, @@ -172,7 +178,8 @@ "end": 134, "ctxt": 0 }, - "data": "\n\n\n" + "data": "\n\n\n", + "raw": "\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/element/basic/output.json b/crates/swc_html_parser/tests/fixture/element/basic/output.json index d444cf69a80..33a42ebc50d 100644 --- a/crates/swc_html_parser/tests/fixture/element/basic/output.json +++ b/crates/swc_html_parser/tests/fixture/element/basic/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -80,7 +81,8 @@ "end": 60, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -93,7 +95,8 @@ "end": 69, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -106,7 +109,8 @@ "end": 77, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -126,7 +130,8 @@ "end": 84, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -149,7 +154,8 @@ "end": 96, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -187,7 +193,8 @@ "end": 119, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -224,7 +231,8 @@ "end": 142, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -247,7 +255,8 @@ "end": 147, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -270,7 +279,8 @@ "end": 154, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -293,7 +303,8 @@ "end": 176, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -329,7 +340,8 @@ "end": 192, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -366,7 +378,8 @@ "end": 243, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -410,7 +423,8 @@ "end": 271, "ctxt": 0 }, - "data": "hey" + "data": "hey", + "raw": "hey" } ], "content": null, @@ -427,7 +441,8 @@ "end": 282, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -461,7 +476,8 @@ "end": 320, "ctxt": 0 }, - "data": "Hello :)" + "data": "Hello :)", + "raw": "Hello :)" } ], "content": null, @@ -474,7 +490,8 @@ "end": 327, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -494,7 +511,8 @@ "end": 340, "ctxt": 0 }, - "data": "\n\ntest\n\n" + "data": "\n\ntest\n\n", + "raw": "\n\ntest\n\n" } ], "content": null, @@ -507,7 +525,8 @@ "end": 348, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -543,7 +562,8 @@ "end": 374, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -579,7 +599,8 @@ "end": 395, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -615,7 +636,8 @@ "end": 415, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -651,7 +673,8 @@ "end": 434, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -671,7 +694,8 @@ "end": 446, "ctxt": 0 }, - "data": "\nTest\n" + "data": "\nTest\n", + "raw": "\nTest\n" } ], "content": null, @@ -684,7 +708,8 @@ "end": 455, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -704,7 +729,8 @@ "end": 464, "ctxt": 0 }, - "data": "test" + "data": "test", + "raw": "test" } ], "content": null, @@ -717,7 +743,8 @@ "end": 479, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/element/body/output.json b/crates/swc_html_parser/tests/fixture/element/body/output.json index 8a9a420e008..ff7b5aeeaa8 100644 --- a/crates/swc_html_parser/tests/fixture/element/body/output.json +++ b/crates/swc_html_parser/tests/fixture/element/body/output.json @@ -71,7 +71,8 @@ "end": 53, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -110,7 +111,8 @@ "end": 83, "ctxt": 0 }, - "data": "test" + "data": "test", + "raw": "test" } ], "content": null, @@ -134,7 +136,8 @@ "end": 96, "ctxt": 0 }, - "data": "test" + "data": "test", + "raw": "test" } ], "content": null, @@ -158,7 +161,8 @@ "end": 107, "ctxt": 0 }, - "data": "Test" + "data": "Test", + "raw": "Test" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/element/br/output.json b/crates/swc_html_parser/tests/fixture/element/br/output.json index c793d9da378..893d396ce9b 100644 --- a/crates/swc_html_parser/tests/fixture/element/br/output.json +++ b/crates/swc_html_parser/tests/fixture/element/br/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -80,7 +81,8 @@ "end": 60, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -93,7 +95,8 @@ "end": 69, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -106,7 +109,8 @@ "end": 77, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -126,7 +130,8 @@ "end": 85, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -146,7 +151,8 @@ "end": 110, "ctxt": 0 }, - "data": " O'er all the hilltops" + "data": " O'er all the hilltops", + "raw": " O'er all the hilltops" }, { "type": "Element", @@ -169,7 +175,8 @@ "end": 132, "ctxt": 0 }, - "data": "\n Is quiet now," + "data": "\n Is quiet now,", + "raw": "\n Is quiet now," }, { "type": "Element", @@ -192,7 +199,8 @@ "end": 160, "ctxt": 0 }, - "data": "\n In all the treetops" + "data": "\n In all the treetops", + "raw": "\n In all the treetops" }, { "type": "Element", @@ -215,7 +223,8 @@ "end": 181, "ctxt": 0 }, - "data": "\n Hearest thou" + "data": "\n Hearest thou", + "raw": "\n Hearest thou" }, { "type": "Element", @@ -238,7 +247,8 @@ "end": 206, "ctxt": 0 }, - "data": "\n Hardly a breath;" + "data": "\n Hardly a breath;", + "raw": "\n Hardly a breath;" }, { "type": "Element", @@ -261,7 +271,8 @@ "end": 249, "ctxt": 0 }, - "data": "\n The birds are asleep in the trees:" + "data": "\n The birds are asleep in the trees:", + "raw": "\n The birds are asleep in the trees:" }, { "type": "Element", @@ -284,7 +295,8 @@ "end": 279, "ctxt": 0 }, - "data": "\n Wait, soon like these" + "data": "\n Wait, soon like these", + "raw": "\n Wait, soon like these" }, { "type": "Element", @@ -307,7 +319,8 @@ "end": 308, "ctxt": 0 }, - "data": "\n Thou too shalt rest." + "data": "\n Thou too shalt rest.", + "raw": "\n Thou too shalt rest." }, { "type": "Element", @@ -330,7 +343,8 @@ "end": 314, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -343,7 +357,8 @@ "end": 328, "ctxt": 0 }, - "data": "\n\n\n" + "data": "\n\n\n", + "raw": "\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/element/button/output.json b/crates/swc_html_parser/tests/fixture/element/button/output.json index 41820ce2c29..29a67f76ad7 100644 --- a/crates/swc_html_parser/tests/fixture/element/button/output.json +++ b/crates/swc_html_parser/tests/fixture/element/button/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -80,7 +81,8 @@ "end": 60, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -93,7 +95,8 @@ "end": 69, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -106,7 +109,8 @@ "end": 77, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -126,7 +130,8 @@ "end": 85, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -164,7 +169,8 @@ "end": 116, "ctxt": 0 }, - "data": "x\n\n\n" + "data": "x\n\n\n", + "raw": "x\n\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/element/caption/output.json b/crates/swc_html_parser/tests/fixture/element/caption/output.json index f52b4248a8d..e163d4bc9c8 100644 --- a/crates/swc_html_parser/tests/fixture/element/caption/output.json +++ b/crates/swc_html_parser/tests/fixture/element/caption/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -80,7 +81,8 @@ "end": 60, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -93,7 +95,8 @@ "end": 69, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -106,7 +109,8 @@ "end": 77, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -126,7 +130,8 @@ "end": 84, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -146,7 +151,8 @@ "end": 96, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -166,7 +172,8 @@ "end": 120, "ctxt": 0 }, - "data": "Example Caption" + "data": "Example Caption", + "raw": "Example Caption" } ], "content": null, @@ -179,7 +186,8 @@ "end": 135, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -210,7 +218,8 @@ "end": 148, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -230,7 +239,8 @@ "end": 157, "ctxt": 0 }, - "data": "Login" + "data": "Login", + "raw": "Login" } ], "content": null, @@ -243,7 +253,8 @@ "end": 171, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -263,7 +274,8 @@ "end": 180, "ctxt": 0 }, - "data": "Email" + "data": "Email", + "raw": "Email" } ], "content": null, @@ -276,7 +288,8 @@ "end": 190, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " } ], "content": null, @@ -289,7 +302,8 @@ "end": 200, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -309,7 +323,8 @@ "end": 213, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -329,7 +344,8 @@ "end": 222, "ctxt": 0 }, - "data": "user1" + "data": "user1", + "raw": "user1" } ], "content": null, @@ -342,7 +358,8 @@ "end": 236, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -362,7 +379,8 @@ "end": 256, "ctxt": 0 }, - "data": "user1@sample.com" + "data": "user1@sample.com", + "raw": "user1@sample.com" } ], "content": null, @@ -375,7 +393,8 @@ "end": 266, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " } ], "content": null, @@ -388,7 +407,8 @@ "end": 276, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -408,7 +428,8 @@ "end": 289, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -428,7 +449,8 @@ "end": 298, "ctxt": 0 }, - "data": "user2" + "data": "user2", + "raw": "user2" } ], "content": null, @@ -441,7 +463,8 @@ "end": 312, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -461,7 +484,8 @@ "end": 332, "ctxt": 0 }, - "data": "user2@sample.com" + "data": "user2@sample.com", + "raw": "user2@sample.com" } ], "content": null, @@ -474,7 +498,8 @@ "end": 342, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " } ], "content": null, @@ -487,7 +512,8 @@ "end": 348, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -504,7 +530,8 @@ "end": 365, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/element/code/output.json b/crates/swc_html_parser/tests/fixture/element/code/output.json index 93a824dd370..49e415ad846 100644 --- a/crates/swc_html_parser/tests/fixture/element/code/output.json +++ b/crates/swc_html_parser/tests/fixture/element/code/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -80,7 +81,8 @@ "end": 60, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -93,7 +95,8 @@ "end": 69, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -106,7 +109,8 @@ "end": 77, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -126,7 +130,8 @@ "end": 84, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -237,7 +242,8 @@ "end": 187, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/element/colgroup/output.json b/crates/swc_html_parser/tests/fixture/element/colgroup/output.json index 741fb049637..f3e3b19cd34 100644 --- a/crates/swc_html_parser/tests/fixture/element/colgroup/output.json +++ b/crates/swc_html_parser/tests/fixture/element/colgroup/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -80,7 +81,8 @@ "end": 60, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -93,7 +95,8 @@ "end": 69, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -106,7 +109,8 @@ "end": 77, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -126,7 +130,8 @@ "end": 84, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -146,7 +151,8 @@ "end": 96, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -166,7 +172,8 @@ "end": 129, "ctxt": 0 }, - "data": "Superheros and sidekicks" + "data": "Superheros and sidekicks", + "raw": "Superheros and sidekicks" } ], "content": null, @@ -179,7 +186,8 @@ "end": 144, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -295,7 +303,8 @@ "end": 232, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -326,7 +335,8 @@ "end": 245, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -346,7 +356,8 @@ "end": 251, "ctxt": 0 }, - "data": " " + "data": " ", + "raw": " " } ], "content": null, @@ -359,7 +370,8 @@ "end": 265, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -392,7 +404,8 @@ "end": 287, "ctxt": 0 }, - "data": "Batman" + "data": "Batman", + "raw": "Batman" } ], "content": null, @@ -405,7 +418,8 @@ "end": 301, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -438,7 +452,8 @@ "end": 322, "ctxt": 0 }, - "data": "Robin" + "data": "Robin", + "raw": "Robin" } ], "content": null, @@ -451,7 +466,8 @@ "end": 336, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -484,7 +500,8 @@ "end": 361, "ctxt": 0 }, - "data": "The Flash" + "data": "The Flash", + "raw": "The Flash" } ], "content": null, @@ -497,7 +514,8 @@ "end": 375, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -530,7 +548,8 @@ "end": 400, "ctxt": 0 }, - "data": "Kid Flash" + "data": "Kid Flash", + "raw": "Kid Flash" } ], "content": null, @@ -543,7 +562,8 @@ "end": 410, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " } ], "content": null, @@ -556,7 +576,8 @@ "end": 416, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -573,7 +594,8 @@ "end": 433, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" } ], "content": null, diff --git a/crates/swc_html_parser/tests/fixture/element/custom-element/output.json b/crates/swc_html_parser/tests/fixture/element/custom-element/output.json index dd00717c1f2..e618ec3c8fa 100644 --- a/crates/swc_html_parser/tests/fixture/element/custom-element/output.json +++ b/crates/swc_html_parser/tests/fixture/element/custom-element/output.json @@ -60,7 +60,8 @@ "end": 45, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -80,7 +81,8 @@ "end": 60, "ctxt": 0 }, - "data": "Document" + "data": "Document", + "raw": "Document" } ], "content": null, @@ -93,7 +95,8 @@ "end": 69, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -106,7 +109,8 @@ "end": 77, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -126,7 +130,8 @@ "end": 84, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" }, { "type": "Element", @@ -174,7 +179,8 @@ "end": 266, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -222,7 +228,8 @@ "end": 315, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -270,7 +277,8 @@ "end": 356, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -290,7 +298,8 @@ "end": 376, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -347,7 +356,8 @@ "end": 427, "ctxt": 0 }, - "data": "Twitter" + "data": "Twitter", + "raw": "Twitter" } ], "content": null, @@ -364,7 +374,8 @@ "end": 452, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -421,7 +432,8 @@ "end": 499, "ctxt": 0 }, - "data": "Facebook" + "data": "Facebook", + "raw": "Facebook" } ], "content": null, @@ -438,7 +450,8 @@ "end": 524, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -495,7 +508,8 @@ "end": 567, "ctxt": 0 }, - "data": "G+" + "data": "G+", + "raw": "G+" } ], "content": null, @@ -512,7 +526,8 @@ "end": 588, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -525,7 +540,8 @@ "end": 606, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -545,7 +561,8 @@ "end": 630, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -565,7 +582,8 @@ "end": 658, "ctxt": 0 }, - "data": "I'm an x-foo-with-markup!" + "data": "I'm an x-foo-with-markup!", + "raw": "I'm an x-foo-with-markup!" } ], "content": null, @@ -578,7 +596,8 @@ "end": 663, "ctxt": 0 }, - "data": "\n" + "data": "\n", + "raw": "\n" } ], "content": null, @@ -591,7 +610,8 @@ "end": 685, "ctxt": 0 }, - "data": "\n\n" + "data": "\n\n", + "raw": "\n\n" }, { "type": "Element", @@ -632,7 +652,8 @@ "end": 725, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -652,7 +673,8 @@ "end": 765, "ctxt": 0 }, - "data": "\n p { color: green; }\n " + "data": "\n p { color: green; }\n ", + "raw": "\n p { color: green; }\n " } ], "content": null, @@ -665,7 +687,8 @@ "end": 778, "ctxt": 0 }, - "data": "\n " + "data": "\n ", + "raw": "\n " }, { "type": "Element", @@ -685,7 +708,8 @@ "end": 846, "ctxt": 0 }, - "data": "I'm in Shadow DOM. My markup was stamped from a