Skip to content

Wrong source and sourceIndex for Sass interpolated selectors #243

Description

@p-szm

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions