Fix div nbsp

pull/3024/head
qintarp 6 years ago
parent 7b4af88ec6
commit f18ad5e6f6

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

@ -66,6 +66,10 @@ export function space() {
return text(' ');
}
export function nbsp() {
return text(String.fromCharCode(160));
}
export function empty() {
return text('');
}

@ -0,0 +1,8 @@
export default {
html: `<div>hello&nbsp;</div>`,
test({ assert, component, target }) {
const text = target.querySelector( 'div' ).textContent;
assert.equal( text.charCodeAt( 5 ), 160 );
}
};

@ -0,0 +1,6 @@
<script>
let name = 'hello';
</script>
<div>{name}&nbsp;</div>
Loading…
Cancel
Save