Skip to content

Commit

Permalink
Merge pull request #906 from m59peacemaker/css-attribute-name-only-bug
Browse files Browse the repository at this point in the history
Fixes #905 css attribute name only bug
  • Loading branch information
Rich-Harris authored Oct 28, 2017
2 parents 1dad8f1 + 97d8125 commit fee5754
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/css/Selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
3 changes: 3 additions & 0 deletions test/css/samples/attribute-selector-only-name/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
cascade: false
};
1 change: 1 addition & 0 deletions test/css/samples/attribute-selector-only-name/expected.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[foo][svelte-xyz]{color:red}[baz][svelte-xyz]{color:blue}
11 changes: 11 additions & 0 deletions test/css/samples/attribute-selector-only-name/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div foo='bar'></div>
<div baz></div>

<style>
[foo] {
color: red;
}
[baz] {
color: blue;
}
</style>

0 comments on commit fee5754

Please sign in to comment.