Skip to content

Commit

Permalink
Warn about usage of non-breaking space (#107)
Browse files Browse the repository at this point in the history
* Throws better error for NBSP tokens [#85]

Co-Authored-By: byara <[email protected]>
  • Loading branch information
byara authored and pago committed Apr 23, 2019
1 parent cf480e0 commit 92bf980
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

- incorrect 'is' method call in melody-types [#20](https://github.com/trivago/melody/issues/20)
- getFocusedPath can break on IE11 for svg elements [#57](https://github.com/trivago/melody/issues/57)
- Warn about usage of non-breaking space [#85](https://github.com/trivago/melody/issues/85)


### Chore & Maintenance
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ 'success_msg' | sort }}
Original file line number Diff line number Diff line change
Expand Up @@ -2277,6 +2277,13 @@ Example:
This is the placeholder content that will be shown to your users while the async component is being loaded."
`;

exports[`Compiler should fail transforming nonbreakable space.template 1`] = `
"ERROR: Unsupported token: Non-breaking space
> 1 | {{ 'success_msg' | sort }}
| ^
2 | "
`;

exports[`Compiler should fail transforming unknown filter.template 1`] = `
"Unknown filter \\"unknown\\"
> 1 | {{ test | unknown }}
Expand Down
5 changes: 5 additions & 0 deletions packages/melody-parser/src/Lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ export default class Lexer {
} else if (CHAR_TO_TOKEN.hasOwnProperty(c)) {
input.next();
return this.createToken(CHAR_TO_TOKEN[c], pos);
} else if (c === '\xa0') {
return this.error(
'Unsupported token: Non-breaking space',
pos
);
} else {
return this.error(`Unknown token ${c}`, pos);
}
Expand Down

0 comments on commit 92bf980

Please sign in to comment.