Skip to content

Commit

Permalink
dont warn on empty block for nbsp - fixes #1658
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Aug 24, 2018
1 parent 4890d4d commit c52a6f0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/validate/html/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function isEmptyBlock(node: Node) {
if (!/Block$/.test(node.type) || !node.children) return false;
if (node.children.length > 1) return false;
const child = node.children[0];
return !child || (child.type === 'Text' && !/\S/.test(child.data));
return !child || (child.type === 'Text' && !/[^ \r\n\f\v\t]/.test(child.data));
}

export default function validateHtml(validator: Validator, html: Node) {
Expand Down
3 changes: 3 additions & 0 deletions test/validator/samples/non-empty-block-dev/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
dev: true
};
3 changes: 3 additions & 0 deletions test/validator/samples/non-empty-block-dev/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{#if x}
 
{/if}
1 change: 1 addition & 0 deletions test/validator/samples/non-empty-block-dev/warnings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]

0 comments on commit c52a6f0

Please sign in to comment.