diff --git a/src/css/Selector.ts b/src/css/Selector.ts index 85922c017b..c66034bccd 100644 --- a/src/css/Selector.ts +++ b/src/css/Selector.ts @@ -224,6 +224,7 @@ function attributeMatches(node: Node, name: string, expectedValue: string, opera if (!attr) return false; if (attr.value === true) return operator === null; if (attr.value.length > 1) return true; + if (!expectedValue) return true; const pattern = operators[operator](expectedValue, caseInsensitive ? 'i' : ''); const value = attr.value[0]; diff --git a/test/css/samples/attribute-selector-only-name/_config.js b/test/css/samples/attribute-selector-only-name/_config.js new file mode 100644 index 0000000000..b37866f9b6 --- /dev/null +++ b/test/css/samples/attribute-selector-only-name/_config.js @@ -0,0 +1,3 @@ +export default { + cascade: false +}; \ No newline at end of file diff --git a/test/css/samples/attribute-selector-only-name/expected.css b/test/css/samples/attribute-selector-only-name/expected.css new file mode 100644 index 0000000000..2217e804d9 --- /dev/null +++ b/test/css/samples/attribute-selector-only-name/expected.css @@ -0,0 +1 @@ +[foo][svelte-xyz]{color:red}[baz][svelte-xyz]{color:blue} \ No newline at end of file diff --git a/test/css/samples/attribute-selector-only-name/input.html b/test/css/samples/attribute-selector-only-name/input.html new file mode 100644 index 0000000000..bb3d98b6bc --- /dev/null +++ b/test/css/samples/attribute-selector-only-name/input.html @@ -0,0 +1,11 @@ +
+ + +