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

selector-exist NPI error #2345

Open
ghost opened this issue Dec 20, 2017 · 4 comments
Open

selector-exist NPI error #2345

ghost opened this issue Dec 20, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Dec 20, 2017

If you run that exact example in a styl file...
http://stylus-lang.com/docs/bifs.html#selector-existsselector

Stylus compiled within web-pack in a vuejs project:

`Module build failed: TypeError: /Users/n/Documents/Code/web-client/src/vars.styl:18:23
14|
15| a
16| font-size 12px
17|
18| selector-exists('.foo') // true
-----------------------------^
19| selector-exists('.foo a') // true
20|

Cannot read property 'indexOf' of undefined

at /Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/normalizer.js:249:24
at Array.forEach (<anonymous>)
at Normalizer.visitGroup (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/normalizer.js:248:15)
at Normalizer.Visitor.visit (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/index.js:28:40)
at Normalizer.visitRoot (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/normalizer.js:170:23)
at Normalizer.Visitor.visit (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/index.js:28:40)
at CachedPathEvaluator.selectorExists (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/functions/selector-exists.js:17:13)
at CachedPathEvaluator.Evaluator.invokeBuiltin (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/evaluator.js:1051:30)
at CachedPathEvaluator.Evaluator.visitCall (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/evaluator.js:516:16)
at CachedPathEvaluator.Visitor.visit (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/index.js:28:40)
at CachedPathEvaluator.Evaluator.visit (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/evaluator.js:160:18)
at CachedPathEvaluator.Evaluator.visitExpression (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/evaluator.js:644:26)
at CachedPathEvaluator.Visitor.visit (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/index.js:28:40)
at CachedPathEvaluator.Evaluator.visit (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/evaluator.js:160:18)
at CachedPathEvaluator.Evaluator.visitBlock (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/evaluator.js:720:39)
at CachedPathEvaluator.Visitor.visit (/Users/n/Documents/Code/web-client/node_modules/stylus/lib/visitor/index.js:28:40)`
@kinesthai
Copy link

kinesthai commented Sep 14, 2018

Hey. I have the same problem. I think is related to where you place the selector-exists function.
Check it out: http://stylus-lang.com/try.html#?code=.test%0A%20%20display%3Ablock%0A%0Aselector-exists(%22.test%22)%3B%0A%0A.another-class%0A%20%20display%3Ablock%0A%0A.and-yet-another%0A%20%20%20content%3A%20%22hello%22

It works if the function is the last thing on the file but not if is in the middle of the code.

@NZX-DeSiGN
Copy link

I ran the same error too ! It's an old issue, can someone look at it please?

@SageStarCodes
Copy link

ran into the same issue, even confirmed it on https://stylus-lang.com/try.html
When selector-exists is at the end of the file it works fine, otherwise the code won't update

code I used to test on https://stylus-lang.com/try.html :
does not work:

body
  position absolute
  &.bar
    position relative

selector-exists("body.bar")

.foo
  color red

works:

body
  position absolute
  &.bar
    position relative

.foo
  color red

selector-exists("body.bar")

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

No branches or pull requests

4 participants