From 78c9fa445c00b68e6a84f125e02c6fae01da3d4c Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Mon, 6 Mar 2017 22:34:45 -0500 Subject: [PATCH] differentiate between nbsp and other whitespace (#348) --- src/parse/patterns.js | 2 +- test/generator/nbsp/_config.js | 8 ++++++++ test/generator/nbsp/main.html | 1 + test/parser/nbsp/input.html | 1 + test/parser/nbsp/output.json | 27 +++++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 test/generator/nbsp/_config.js create mode 100644 test/generator/nbsp/main.html create mode 100644 test/parser/nbsp/input.html create mode 100644 test/parser/nbsp/output.json diff --git a/src/parse/patterns.js b/src/parse/patterns.js index 313f40a46415..8fea930aa68e 100644 --- a/src/parse/patterns.js +++ b/src/parse/patterns.js @@ -1 +1 @@ -export const whitespace = /\s/; +export const whitespace = /[ \t\r\n]/; diff --git a/test/generator/nbsp/_config.js b/test/generator/nbsp/_config.js new file mode 100644 index 000000000000..c09c14e7c413 --- /dev/null +++ b/test/generator/nbsp/_config.js @@ -0,0 +1,8 @@ +export default { + html: ` `, + + test ( assert, component, target ) { + const text = target.querySelector( 'span' ).textContent; + assert.equal( text.charCodeAt( 0 ), 160 ); + } +}; \ No newline at end of file diff --git a/test/generator/nbsp/main.html b/test/generator/nbsp/main.html new file mode 100644 index 000000000000..11cd588757a4 --- /dev/null +++ b/test/generator/nbsp/main.html @@ -0,0 +1 @@ +  \ No newline at end of file diff --git a/test/parser/nbsp/input.html b/test/parser/nbsp/input.html new file mode 100644 index 000000000000..11cd588757a4 --- /dev/null +++ b/test/parser/nbsp/input.html @@ -0,0 +1 @@ +  \ No newline at end of file diff --git a/test/parser/nbsp/output.json b/test/parser/nbsp/output.json new file mode 100644 index 000000000000..d8cbb594f6e9 --- /dev/null +++ b/test/parser/nbsp/output.json @@ -0,0 +1,27 @@ +{ + "hash": 2678229240, + "html": { + "start": 0, + "end": 19, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 19, + "type": "Element", + "name": "span", + "attributes": [], + "children": [ + { + "start": 6, + "end": 12, + "type": "Text", + "data": " " + } + ] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file