|
|
|
@ -141,7 +141,7 @@ function sort_const_tags(nodes, state) {
|
|
|
|
|
* @param {TransformState & { options: ValidatedCompileOptions }} state
|
|
|
|
|
* @param {boolean} preserve_whitespace
|
|
|
|
|
* @param {boolean} preserve_comments
|
|
|
|
|
* @param {boolean} [prevent_template_cloning]
|
|
|
|
|
* @param {boolean} [is_functional_template_mode]
|
|
|
|
|
*/
|
|
|
|
|
export function clean_nodes(
|
|
|
|
|
parent,
|
|
|
|
@ -154,7 +154,7 @@ export function clean_nodes(
|
|
|
|
|
// rather than from `ClientTransformState` and `ServerTransformState`
|
|
|
|
|
preserve_whitespace,
|
|
|
|
|
preserve_comments,
|
|
|
|
|
prevent_template_cloning
|
|
|
|
|
is_functional_template_mode
|
|
|
|
|
) {
|
|
|
|
|
if (!state.analysis.runes) {
|
|
|
|
|
nodes = sort_const_tags(nodes, state);
|
|
|
|
@ -276,13 +276,13 @@ export function clean_nodes(
|
|
|
|
|
// initial newline inside a `<pre>` is disregarded, if not followed by another newline
|
|
|
|
|
if (
|
|
|
|
|
parent.type === 'RegularElement' &&
|
|
|
|
|
(parent.name === 'pre' || (prevent_template_cloning && parent.name === 'textarea')) &&
|
|
|
|
|
(parent.name === 'pre' || (is_functional_template_mode && parent.name === 'textarea')) &&
|
|
|
|
|
first?.type === 'Text'
|
|
|
|
|
) {
|
|
|
|
|
const text = first.data.replace(regex_starts_with_newline, '');
|
|
|
|
|
if (text !== first.data) {
|
|
|
|
|
const tmp = text.replace(regex_starts_with_newline, '');
|
|
|
|
|
if (text === tmp || prevent_template_cloning) {
|
|
|
|
|
if (text === tmp || is_functional_template_mode) {
|
|
|
|
|
first.data = text;
|
|
|
|
|
first.raw = first.raw.replace(regex_starts_with_newline, '');
|
|
|
|
|
if (first.data === '') {
|
|
|
|
|