|
|
|
|
@ -50,11 +50,12 @@ function trimmable_at(child, next_sibling) {
|
|
|
|
|
// Whitespace is trimmable if one of the following is true:
|
|
|
|
|
// The child and its sibling share a common nearest each block (not at an each block boundary)
|
|
|
|
|
// The next sibling's previous node is an each block
|
|
|
|
|
return (next_sibling.node.find_nearest(/EachBlock/) === child.find_nearest(/EachBlock/) ||
|
|
|
|
|
next_sibling.node.prev.type === 'EachBlock');
|
|
|
|
|
return (
|
|
|
|
|
next_sibling.node.find_nearest(/EachBlock/) === child.find_nearest(/EachBlock/) ||
|
|
|
|
|
next_sibling.node.prev.type === 'EachBlock'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
export default class FragmentWrapper {
|
|
|
|
|
|
|
|
|
|
/** @type {import('./shared/Wrapper.js').default[]} */
|
|
|
|
|
nodes;
|
|
|
|
|
|
|
|
|
|
@ -101,26 +102,30 @@ export default class FragmentWrapper {
|
|
|
|
|
: !child.has_ancestor('EachBlock');
|
|
|
|
|
if (should_trim && !child.keep_space()) {
|
|
|
|
|
data = trim_end(data);
|
|
|
|
|
if (!data)
|
|
|
|
|
continue;
|
|
|
|
|
if (!data) continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// glue text nodes (which could e.g. be separated by comments) together
|
|
|
|
|
if (last_child && last_child.node.type === 'Text') {
|
|
|
|
|
( /** @type {import('./Text.js').default} */(last_child)).data = data + ( /** @type {import('./Text.js').default} */(last_child)).data;
|
|
|
|
|
/** @type {import('./Text.js').default} */ (last_child).data =
|
|
|
|
|
data + /** @type {import('./Text.js').default} */ (last_child).data;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
const wrapper = new Text(renderer, block, parent, child, data);
|
|
|
|
|
if (wrapper.skip)
|
|
|
|
|
continue;
|
|
|
|
|
if (wrapper.skip) continue;
|
|
|
|
|
this.nodes.unshift(wrapper);
|
|
|
|
|
link(last_child, (last_child = wrapper));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
const Wrapper = wrappers[child.type];
|
|
|
|
|
if (!Wrapper || (child.type === 'Comment' && !renderer.options.preserveComments))
|
|
|
|
|
continue;
|
|
|
|
|
const wrapper = new Wrapper(renderer, block, parent, child, strip_whitespace, last_child || next_sibling);
|
|
|
|
|
if (!Wrapper || (child.type === 'Comment' && !renderer.options.preserveComments)) continue;
|
|
|
|
|
const wrapper = new Wrapper(
|
|
|
|
|
renderer,
|
|
|
|
|
block,
|
|
|
|
|
parent,
|
|
|
|
|
child,
|
|
|
|
|
strip_whitespace,
|
|
|
|
|
last_child || next_sibling
|
|
|
|
|
);
|
|
|
|
|
this.nodes.unshift(wrapper);
|
|
|
|
|
link(last_child, (last_child = wrapper));
|
|
|
|
|
}
|
|
|
|
|
@ -155,7 +160,3 @@ export default class FragmentWrapper {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|