Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/__tests__/namespaces.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {test} from './util/helpers.mjs';
import {test, throws} from './util/helpers.mjs';

test('match tags in the postcss namespace', 'postcss|button', (t, tree) => {
t.deepEqual(tree.nodes[0].nodes[0].namespace, 'postcss');
Expand Down Expand Up @@ -76,3 +76,10 @@ test('ns alias for namespace', 'f\\oo|h1.foo', (t, tree) => {
t.deepEqual(tag.namespace, 'bar');
t.deepEqual(tag.ns, 'bar');
});

throws('lone pipe symbol', '|');
throws('lone pipe symbol with leading spaces', ' |');
throws('lone pipe symbol with trailing spaces', '| ');
throws('lone pipe symbol with surrounding spaces', ' | ');
throws('trailing pipe symbol with a namespace', 'foo| ');
throws('trailing pipe symbol with any namespace', '*| ');
6 changes: 6 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ export default class Parser {
return this.error(`Unexpected '${this.content()}'. Escaping special characters with \\ may help.`, this.currToken[TOKEN.START_POS]);
}

unexpectedPipe () {
return this.error(`Unexpected '|'.`, this.currToken[TOKEN.START_POS]);
}

namespace () {
const before = this.prevToken && this.content(this.prevToken) || true;
if (this.nextToken[TOKEN.TYPE] === tokens.word) {
Expand All @@ -655,6 +659,8 @@ export default class Parser {
this.position ++;
return this.universal(before);
}

this.unexpectedPipe();
}

nesting () {
Expand Down