Skip to content

Commit a362b43

Browse files
authored
Merge pull request #352 from sveltejs/gh-348
differentiate between nbsp and other whitespace
2 parents 93b0b0e + ce6178d commit a362b43

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

src/parse/patterns.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const whitespace = /\s/;
1+
export const whitespace = /[ \t\r\n]/;

test/generator/nbsp/_config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
html: `<span>&nbsp;</span>`,
3+
4+
test ( assert, component, target ) {
5+
const text = target.querySelector( 'span' ).textContent;
6+
assert.equal( text.charCodeAt( 0 ), 160 );
7+
}
8+
};

test/generator/nbsp/main.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<span>&nbsp;</span>

test/parser/nbsp/input.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<span>&nbsp;</span>

test/parser/nbsp/output.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"hash": 2678229240,
3+
"html": {
4+
"start": 0,
5+
"end": 19,
6+
"type": "Fragment",
7+
"children": [
8+
{
9+
"start": 0,
10+
"end": 19,
11+
"type": "Element",
12+
"name": "span",
13+
"attributes": [],
14+
"children": [
15+
{
16+
"start": 6,
17+
"end": 12,
18+
"type": "Text",
19+
"data": " "
20+
}
21+
]
22+
}
23+
]
24+
},
25+
"css": null,
26+
"js": null
27+
}

0 commit comments

Comments
 (0)