Skip to content

Commit

Permalink
differentiate between nbsp and other whitespace (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Mar 7, 2017
1 parent d8dbe4e commit ce6178d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parse/patterns.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const whitespace = /\s/;
export const whitespace = /[ \t\r\n]/;
8 changes: 8 additions & 0 deletions test/generator/nbsp/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
html: `<span>&nbsp;</span>`,

test ( assert, component, target ) {
const text = target.querySelector( 'span' ).textContent;
assert.equal( text.charCodeAt( 0 ), 160 );
}
};
1 change: 1 addition & 0 deletions test/generator/nbsp/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span>&nbsp;</span>
1 change: 1 addition & 0 deletions test/parser/nbsp/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span>&nbsp;</span>
27 changes: 27 additions & 0 deletions test/parser/nbsp/output.json
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit ce6178d

Please sign in to comment.