Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error with mixin using map for parameters #5

Open
strarsis opened this issue Nov 15, 2016 · 1 comment · May be fixed by #48
Open

Parse error with mixin using map for parameters #5

strarsis opened this issue Nov 15, 2016 · 1 comment · May be fixed by #48
Labels

Comments

@strarsis
Copy link

scss-parser throws a parse error when a mixin using a map for parameters (also see https://www.sitepoint.com/sass-multiple-arguments-lists-or-arglist/) is included.

Input SCSS:

.test {
  @include some-mixin((
    param1: 2,
    param2: 100%
  )...);
}

Parse error:

Unhandled rejection Error: Selector ("class") expected "identifier" or "interpolation" (5:6)
    at InputStream.err ([...]/node_modules/scss-parser/dist/input-stream.js:122:13)
    at Object.err ([...]/node_modules/scss-parser/dist/input-stream.js:161:20)
    at TokenStream.err ([...]/node_modules/scss-parser/dist/token-stream.js:297:40)
    at Object.err ([...]/node_modules/scss-parser/dist/token-stream.js:634:20)
    at Parser.parse_selector ([...]/node_modules/scss-parser/dist/parse.js:728:21)
    at [...]/node_modules/scss-parser/dist/parse.js:435:25
    at Parser.maybe_function ([...]/node_modules/scss-parser/dist/parse.js:609:14)
    at Parser.parse_atom ([...]/node_modules/scss-parser/dist/parse.js:420:19)
    at Parser.parse_expression ([...]/node_modules/scss-parser/dist/parse.js:394:25)
    at Parser.parse_arguments ([...]/node_modules/scss-parser/dist/parse.js:581:37)
    at Parser.parse_at_rule ([...]/node_modules/scss-parser/dist/parse.js:665:27)
    at Parser.parse_node ([...]/node_modules/scss-parser/dist/parse.js:350:36)
    at Parser.parse_block ([...]/node_modules/scss-parser/dist/parse.js:539:25)
    at Parser.parse_rule ([...]/node_modules/scss-parser/dist/parse.js:692:24)
    at Parser.parse_node ([...]/node_modules/scss-parser/dist/parse.js:357:51)
    at Parser.parse_stylesheet ([...]/node_modules/scss-parser/dist/parse.js:267:25)
@kaelig kaelig added the bug label Jan 27, 2017
@smallstepstoday
Copy link

This seems to relate to the ellipsis (variable arguments), because the same error is thrown when the following code is executed:

let { parse, stringify } = require('scss-parser')

// Create an AST from a string of SCSS
let ast = parse('@mixin box-shadow($shadow...) { @if enable-shadows { box-shadow: $shadow; } }')
// Modify the AST (see below for a better way to do this)
ast.value[0].value[0].value[0].value[0].value = 'world'
// Convert the modified AST back to SCSS
let scss = stringify(ast) // .world { color: $red; }

debagger added a commit to debagger/scss-parser that referenced this issue Oct 3, 2019
alexjgustafson added a commit to alexjgustafson/scss-parser that referenced this issue Jan 10, 2023
The last argument in a @mixin can be an arbitrary
keyword argument.

See Sass specification:
https://sass-lang.com/documentation/at-rules/mixin#taking-arbitrary-keyword-arguments

Addresses issue in main project:
salesforce-ux#5
@alexjgustafson alexjgustafson linked a pull request Jan 10, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants