Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #191 from zalando/tailor-parsting-failure
Browse files Browse the repository at this point in the history
Tailor fails to parse template with comments inside
  • Loading branch information
DeTeam authored Oct 20, 2017
2 parents 681aed5 + 05eec49 commit 832f078
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ module.exports = class Transform {
const slotMap = new Map([['default', []]]);
const nodes = treeAdapter.getChildNodes(root);
nodes.forEach(node => {
if (!treeAdapter.isTextNode(node)) {
if (
!treeAdapter.isTextNode(node) &&
!treeAdapter.isCommentNode(node)
) {
const { slot = 'default' } = node.attribs;
const slotNodes = slotMap.get(slot) || [];
const updatedSlotNodes = [...slotNodes, node];
Expand Down
6 changes: 6 additions & 0 deletions tests/parse-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ describe('parseTemplate', () => {
assert(err instanceof Error);
});
});

it('should parse templates with comments inside', done => {
parseTempatePartial('<div></div>', '<!-- nice comment -->')
.then(() => done())
.catch(done);
});
});

0 comments on commit 832f078

Please sign in to comment.