nathggns / nesting.js Goto Github PK
View Code? Open in Web Editor NEWPolyfill for CSS Nesting.
Polyfill for CSS Nesting.
Nesting doesn't work at all within media queries. Doesn't error or anything, just leaves css within media queries alone.
Any comments that cover a full nested block wil not work, as the block is moved out of the comment.
For example:
/* This */
body {
/* & a {
color: #333;
} */
}
/* Will compile to something like */
body { /**/ }
body a { color: #333; }
/* When it should compile to */
body { /* & a { color: #333; } */ }
But, comments actually within the nested blocks work fine.
When a block is nested within a parent that is a selector list, or when a selector list is nested, nesting.js acts a bit weirdly.
This:
strong, b {
font-weight: bold;
& a { font-weight: normal; }
}
compiles to something like
strong, b {
font-weight: bold;
}
strong, b a {
font-weight: normal;
}
when it should compile to
strong, b {
font-weight: bold;
}
strong a, b a {
font-weight: normal;
}
The CSS working group states that the &
operator is required to state that nesting is about to happen. In Nesting.js
, this isn't required. This should be fixed so that it follows the official syntax as close as possible.
The official syntax looks a little like
p {
color: #222;
& a {
color: #444;
&:hover { background: #fafafa; }
}
}
Modernizr is included with Nesting.js
, but it isn't being used. It should either be removed, or used to test for native Nesting support, to support forward-compatibility.
Any rules outside blocks will break Nesting.js. This includes media queries, imports, font-faces, and any of those other things.
For example, this will break Nesting.js.
@media screen and (min-width: 20px) {
body {
background: #f00;
}
}
Cannot use psuedo selectors or elements when nesting.
body {
&:hover { background: #000; }
}
will turn into something like
body :hover { background: #000; }
instead of
body:hover { background: #000; }
Any special blocks will break Nesting.js. This includes @font-face
and @media
blocks.
Nesting.js will choke on the following code.
@media screen and (min-width: 100px) {
body { width: 100%; }
}
body {
background: #000;
& header {
height: 50px;
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.