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

Should matched selectors be returned alongside declarations? #1

Open
glortho opened this issue Dec 21, 2018 · 0 comments
Open

Should matched selectors be returned alongside declarations? #1

glortho opened this issue Dec 21, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@glortho
Copy link
Owner

glortho commented Dec 21, 2018

This may not be useful in simple string matching like '.foo' but what about for regex matches?

For example, here is functionality as of v0.3.0:

./stylesheet.css

.foo {
  color: blue;
}

.footer {
  color: black;
}
declarations = styledImport('./stylesheet.css', /foo/)
// declarations is 'color: blue;'

declarations = styledImport('./stylesheet.css', /foo/g)
// declarations is ['color: blue;', 'color: black;']

Would it be better to return the selectors also? For example:

matches = styledImport('./stylesheet.css', /foo/g)

// matches could be:

[{
  selector: '.foo', 
  declarations: 'color: blue;'
}, {
  selector: '.footer', 
  declarations: 'color: black;'
}]

There are probably other cases where having selectors back would be useful.

It could be behind an options flag of some sort.

@glortho glortho added the enhancement New feature or request label Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant