csstools / parser Goto Github PK
View Code? Open in Web Editor NEWCSS Parser
Home Page: https://csstools.github.io/parser/
CSS Parser
Home Page: https://csstools.github.io/parser/
"engines": {
"node": ">= 14.0.0"
}
I guess this version of rollup requires you to have 14 or greater, as I switch, this bit me.
๐ nice job with the tokenizer
From specs: https://drafts.csswg.org/css-syntax/#consume-number
If the next 2 or 3 input code points are U+0045 LATIN CAPITAL LETTER E (E) or U+0065 LATIN SMALL LETTER E (e), optionally followed by U+002D HYPHEN-MINUS (-) or U+002B PLUS SIGN (+), followed by a digit, then:
- Consume them.
- Append them to repr.
- Set type to "number".
- While the next input code point is a digit, consume it and append it to repr.
The logic looks okay.. but I think you forgot to consume the sign:
parser/src/tokenize/tokenize.js
Line 618 in 1e59d1b
&& isInteger(cssText.charCodeAt(shut + 2))
It's + 2
because you didn't consume the sign (didn't do ++shut
, so shut
still points to e
|E
). Otherwise the check is always false.
#c {
border: 1e+1px
}
From specs, consume number
(called by consume numeric token
) should return 6. convert repl to number
which is described here: https://drafts.csswg.org/css-syntax-3/#convert-string-to-number
Since the tokenizer is written in JS, you can pretty much ignore it all and just do parseFloat(this.value)
. Could CSSNumber
return, for example:
CSSNumber {
value: "12e+1",
number: 120, // Result of parseFloat(value)
unit: "px",
}
Anyways, this last thing is just a suggestion and I'm not sure how parseFloat
would affect performance ๐
Is there a reason this isn't on npm?
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.