Changed to Conduitry's suggestion

pull/3024/head
qintarp 6 years ago
parent dea4149c0e
commit e61ecbeb0a

@ -12,7 +12,7 @@ export default class Text extends Node {
super(component, parent, scope, info);
this.data = info.data;
if (!component.component_options.preserveWhitespace) {
if (!component.component_options.preserveWhitespace && !/[\S\u00A0]/.test(info.data)) {
let node = parent;
while (node) {
if (node.type === 'Element' && node.name === 'pre') {
@ -21,7 +21,7 @@ export default class Text extends Node {
node = node.parent;
}
this.use_space = true;
}
}
}

@ -54,7 +54,7 @@ export default class TextWrapper extends Wrapper {
block.add_element(
this.var,
`@text(${stringify(this.data)})`,
this.node.use_space ? `@space()` : `@text(${stringify(this.data)})`,
parent_nodes && `@claim_text(${parent_nodes}, ${stringify(this.data)})`,
parent_node
);

@ -62,6 +62,9 @@ export function text(data: string) {
return document.createTextNode(data);
}
export function space() {
return text(' ');
}
export function empty() {
return text('');

Loading…
Cancel
Save