diff --git a/src/compiler/compile/nodes/Text.ts b/src/compiler/compile/nodes/Text.ts index 7500f5ff30d9..a4514f56f26e 100644 --- a/src/compiler/compile/nodes/Text.ts +++ b/src/compiler/compile/nodes/Text.ts @@ -12,7 +12,7 @@ export default class Text extends Node { super(component, parent, scope, info); this.data = info.data; - if (!component.component_options.preserveWhitespace && !/\S/.test(info.data)) { + if (!component.component_options.preserveWhitespace && !/[\S\u00A0]/.test(info.data)) { let node = parent; while (node) { if (node.type === 'Element' && node.name === 'pre') { diff --git a/test/runtime/samples/nbsp-div/_config.js b/test/runtime/samples/nbsp-div/_config.js new file mode 100644 index 000000000000..6026af2c9090 --- /dev/null +++ b/test/runtime/samples/nbsp-div/_config.js @@ -0,0 +1,19 @@ +export default { + html: `
 hello
+
 hello  
+
 hello   hello
`, + + test({ assert, component, target }) { + var divList = target.querySelectorAll('div') + assert.equal( divList[0].textContent.charCodeAt( 0 ), 160 ); + assert.equal( divList[1].textContent.charCodeAt( 0 ), 160 ); + assert.equal( divList[1].textContent.charCodeAt( 6 ), 160 ); + assert.equal( divList[1].textContent.charCodeAt( 7 ), 160 ); + assert.equal( divList[2].textContent.charCodeAt( 0 ), 160 ); + assert.equal( divList[2].textContent.charCodeAt( 6 ), 160 ); + assert.equal( divList[2].textContent.charCodeAt( 7 ), 32 );//normal space + assert.equal( divList[2].textContent.charCodeAt( 8 ), 160 ); + + + } +}; \ No newline at end of file diff --git a/test/runtime/samples/nbsp-div/main.svelte b/test/runtime/samples/nbsp-div/main.svelte new file mode 100644 index 000000000000..64557bfeb142 --- /dev/null +++ b/test/runtime/samples/nbsp-div/main.svelte @@ -0,0 +1,7 @@ + + +
 {name}
+
 {name}  
+
 {name}   {name}
\ No newline at end of file