Skip to content

Commit ca9e4c0

Browse files
HauptmannEckshellscape
authored andcommitted
#96 - Add extra check for not adding params from brackets. (#97)
* #96 - Add extra check for not adding params from brackets. * #96 - Update comment
1 parent 39919d6 commit ca9e4c0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/less-parser.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ export default class LessParser extends Parser {
316316
}
317317
}
318318

319-
// we don't want to add params for pseudo-selectors that utilize parens (#56)
320-
if ((extend || !colon) && (brackets.length > 0 || type === 'brackets' || params[0])) {
319+
// we don't want to add params for pseudo-selectors that utilize parens (#56) or bracket selectors (#96)
320+
if ((extend || !colon) && (brackets.length > 0 || type === 'brackets' || params[0]) && brackets[0] !== ']') {
321321
params.push(token);
322322
}
323323

test/parser/params.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,13 @@ describe('Parser', () => {
1515
expect(root.first.params).to.be.undefined;
1616
});
1717

18+
it('should not assign parameters for bracket selectors', () => {
19+
const code = '.test1,.test2[test=test] {}';
20+
const root = parse(code);
21+
22+
expect(root.first.selector).to.eql('.test1,.test2[test=test]');
23+
expect(root.first.params).to.be.undefined;
24+
});
25+
1826
});
1927
});

0 commit comments

Comments
 (0)