mirror of https://github.com/sveltejs/svelte
pull/2258/head
parent
21d56c9ee3
commit
2b1aa77f29
@ -1,11 +1,26 @@
|
||||
import Node from './shared/Node';
|
||||
import Component from '../Component';
|
||||
import TemplateScope from './shared/TemplateScope';
|
||||
|
||||
export default class Text extends Node {
|
||||
type: 'Text';
|
||||
data: string;
|
||||
use_space = false;
|
||||
|
||||
constructor(component, parent, scope, info) {
|
||||
constructor(component: Component, parent: Node, scope: TemplateScope, info: any) {
|
||||
super(component, parent, scope, info);
|
||||
this.data = info.data;
|
||||
|
||||
if (!component.component_options.preserveWhitespace && !/\S/.test(info.data)) {
|
||||
let node = parent;
|
||||
while (node) {
|
||||
if (node.type === 'Element' && node.name === 'pre') {
|
||||
return;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
this.use_space = true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue