Merge pull request from Swatinem/claim-space

Introduce a `claim_space` helper
pull/3527/head
Rich Harris 6 years ago committed by GitHub
commit 4d3f32ddde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -66,11 +66,12 @@ export default class TextWrapper extends Wrapper {
render(block: Block, parent_node: string, parent_nodes: string) {
if (this.skip) return;
const use_space = this.use_space();
block.add_element(
this.var,
this.use_space() ? `@space()` : `@text(${stringify(this.data)})`,
parent_nodes && `@claim_text(${parent_nodes}, ${stringify(this.data)})`,
use_space ? `@space()` : `@text(${stringify(this.data)})`,
parent_nodes && (use_space ? `@claim_space(${parent_nodes})` : `@claim_text(${parent_nodes}, ${stringify(this.data)})`),
parent_node
);
}

@ -164,6 +164,10 @@ export function claim_text(nodes, data) {
return text(data);
}
export function claim_space(nodes) {
return claim_text(nodes, ' ');
}
export function set_data(text, data) {
data = '' + data;
if (text.data !== data) text.data = data;

Loading…
Cancel
Save