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

Doesn't walk incomplete declaration #9

Open
knownasilya opened this issue Aug 27, 2019 · 6 comments
Open

Doesn't walk incomplete declaration #9

knownasilya opened this issue Aug 27, 2019 · 6 comments

Comments

@knownasilya
Copy link

knownasilya commented Aug 27, 2019

.container {
  max-width: rem(800px);
  margin: 3rem auto 5rem;
  padding: 0 2rem;
  font-size

  @media (max-width: rem(800px)) {
    flex-direction: column;
    margin-top: 0.5rem;
  }
}

It ignores font-size (with or without :, no difference). Mainly I'm using this for autocomplete.
My code is here: https://github.com/subsetcss/parser/blob/master/src/index.ts#L42

walked declarations go from padding to flex-direction.

@ai
Copy link
Member

ai commented Aug 27, 2019

Yeap, because font-size doesn't looks like declaration for the parser. Parser has no list of the declarations, as result it can't detect that it is properties or nested rule selector.

If you have an idea how to detect it, feel free to send PR.

@knownasilya
Copy link
Author

What about an option to walkDecls like walkUnknowns: true so it parses the line but if it can't decide what type it is it simply returns the value and line number and type: 'unknown'?

@ai
Copy link
Member

ai commented Aug 27, 2019

Hm. We can do it without adding a new type (since it could brake many plugins). We can generate nodes as now, but set Node#raws.safeParserUnknown (or use Symbol to avoid parser name in prefix).

You will be able to find it by walking through Node#nodes manually (since it will be hard to change PostCSS core AST for non-standard extension). It will not be hard.

But you will need to send PR for it.

@knownasilya
Copy link
Author

@ai where would I start to implement this? would I have to completely reimplement decls here ins safe parser (based on the normal decls)?

@ai
Copy link
Member

ai commented Aug 30, 2019

We should try to change only postcss-safe-parser

@tycan1193
Copy link

.container {
  max-width: rem(800px);
  margin: 3rem auto 5rem;
  padding: 0 2rem;
  font-size

  @media (max-width: rem(800px)) {
    flex-direction: column;
    margin-top: 0.5rem;
  }
}

Nó bỏ qua font-size(có hoặc không có :, không có sự khác biệt). Chủ yếu tôi đang sử dụng tính năng này để tự động hoàn thành. Mã của tôi ở đây: https://github.com/subsetcss/parser/blob/master/src/index.ts#L42

khai báo đã đi từ paddingđến flex-direction.

.container {
max-width: rem(800px);
margin: 3rem auto 5rem;
padding: 0 2rem;
font-size

@media (max-width: rem(800px)) {
flex-direction: column;
margin-top: 0.5rem;
}
}

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

No branches or pull requests

3 participants