Skip to content

Commit 41f9816

Browse files
committedJun 30, 2020
fix: Attribute intersections interpreted incorrectly during compilation.
1 parent abd57cc commit 41f9816

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
 

Diff for: ‎packages/@css-blocks/core/src/BlockTree/Block.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,15 @@ export class Block
485485
return [klass, 0];
486486
}
487487
} else if (isAttributeNode(node)) {
488-
let attr = this.rootClass.ensureAttributeValue(toAttrToken(node));
488+
let prevNode = node.prev();
489+
while (prevNode && !(selectorParser.isClassName(prevNode) || isRootNode(prevNode))) {
490+
prevNode = prevNode.prev();
491+
}
492+
if (!prevNode) {
493+
throw new Error("internal error - illegal selector encountered after validation.");
494+
}
495+
let klass = this.getClass(prevNode.value);
496+
let attr = klass?.getAttributeValue(toAttrToken(node));
489497
if (attr) {
490498
return [attr, 0];
491499
} else {

Diff for: ‎packages/@css-blocks/core/test/BlockParser/block-composition-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class BlockNames extends BEMProcessor {
155155
indented`
156156
.test-block__bar { }
157157
.test-block__bar--active { }
158-
.test-block__bar--color.test-block--inverse { background: blue; }
158+
.test-block__bar--color.test-block__bar--inverse { background: blue; }
159159
/* Source: foo/bar/test-block.css
160160
* :scope (.test-block)
161161
* composes:

0 commit comments

Comments
 (0)
Please sign in to comment.