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
28 changes: 28 additions & 0 deletions src/__fixtures__/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,19 @@ export const tests: [
],
"star tag namespace",
],
[
"|bar",
[
[
{
name: "bar",
type: "tag",
namespace: "",
},
],
],
"without namespace",
],
[
"*|*",
[
Expand Down Expand Up @@ -870,6 +883,21 @@ export const tests: [
],
"basic attribute namespace, existential",
],
[
"[|bar]",
[
[
{
action: "exists",
name: "bar",
type: "attribute",
namespace: "",
value: "",
},
],
],
"without namespace, existential",
],
[
"[foo|bar='baz' i]",
[
Expand Down
4 changes: 4 additions & 0 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ function parseSelector(
selectorIndex += 1;
name = "*";
} else if (reName.test(selector.slice(selectorIndex))) {
if (selector.charAt(selectorIndex) === "|") {
namespace = "";
selectorIndex += 1;
}
name = getName(0);
} else {
/*
Expand Down
2 changes: 1 addition & 1 deletion src/stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function getNamespacedName(token: {
}

function getNamespace(namespace: string | null): string {
return namespace
return namespace !== null
? `${namespace === "*" ? "*" : escapeName(namespace)}|`
: "";
}
Expand Down