Coder Social home page Coder Social logo

Support arbitrary `@`-blocks about css HOT 4 CLOSED

reworkcss avatar reworkcss commented on June 12, 2024
Support arbitrary `@`-blocks

from css.

Comments (4)

lydell avatar lydell commented on June 12, 2024

Lots of the parsing code and most of the AST documentation is about the myriad of different at-rules. I’d suggest we’d parse them like this instead:

  • type: 'at-rule'
  • name: String. The part directly after the @, such as “media”, “viewport”, “charset”, “whatever”.
  • value: String. The part that comes after the name, and before the ; or {. This string may be empty.
  • declarations: Array of nodes with the types declaration and comment, or null. If the at-rule has a block, and that block can be parsed as declarations this property represents those declarations. Otherwise it is null. @page is an example.
  • rules: Array of nodes with the types rule, at-rule and comment, or null. If the at-rule has a block, and that block can be parsed as rules this property represents those rules. Otherwise it is null. @media is an example.

All at-rules have .value. Some have .declarations. Some have .rules. Some have neither (such as @charset), but none have both.

Pros:

  • Future at-rules automatically supported.
  • Simpler code.
  • Less properties to know about in the AST: no more .media, .document, .charset, etc.—just .value!
  • Less documentation to read.
  • Consistent with the rest of the parsing: Only parse syntax, not semantics.

This would be for css 3.0.

from css.

necolas avatar necolas commented on June 12, 2024

Yeah that sounds good.

from css.

DracoBlue avatar DracoBlue commented on June 12, 2024

👍

from css.

mtlehtin avatar mtlehtin commented on June 12, 2024

+1

We have the same issue when parsin third party css (AlloyUI)

@-ms-viewport {
  .wrapper {
    width: device-width; } }

@-ms-keyframes progress-bar-stripes {
  .aui from {
    background-position: 40px 0; }
  .aui to {
    background-position: 0 0; } }

Is causing error: missing '}'

from css.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.