Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Wrong source and sourceIndex for Sass interpolated selectors

Open
#243 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, sass
Domain
tooling

Research direction

Start with the inline Sass selector reproduction and the parser code that assigns source positions and sourceIndex to interpolated class nodes. Update the behavior so the interpolated selector reports the expected columns and index, then verify both the Sass and normal selector examples pass.

Written by the indexing model from the issue text.

Description

Repro:

test('Sass selector', '.#{$classname}', (t, tree) => {
    const node = tree.nodes[0].nodes[0];
    t.deepEqual(node.type, "class"); // Ok
    t.deepEqual(node.value, "#{$classname}"); // Ok
    t.deepEqual(node.source.start.column, 1); // Fail. Received: 5
    t.deepEqual(node.source.end.column, 14); // Fail. Received: 18
    t.deepEqual(node.sourceIndex, 0); // Fail. Received: 4
});

Compare with this selector that has the same length:

test('Normal selector', '.XXXclassnameX', (t, tree) => {
    const node = tree.nodes[0].nodes[0];
    t.deepEqual(node.type, "class"); // Ok
    t.deepEqual(node.value, "XXXclassnameX"); // Ok
    t.deepEqual(node.source.start.column, 1); // Ok
    t.deepEqual(node.source.end.column, 14); // Ok
    t.deepEqual(node.sourceIndex, 0); // Ok
});

I tried to look at the parser code to figure out what's wrong but I didn't manage to figure this one out.

Dominant language
JavaScript
Stars
214
Forks
63
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from postcss/postcss-selector-parser

All issues in postcss/postcss-selector-parser

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.