css-tree
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -171,2 +171,27 @@ { | ||
}, | ||
"content": { | ||
"comment": "https://www.w3.org/TR/css-content-3/#content-property", | ||
"syntax": "normal | none | [ <content-replacement> | <content-list> ] [/ [ <string> | <counter> ]+ ]?" | ||
}, | ||
"counter-reset": { | ||
"comment": "<custom-ident> -> <counter-name>", | ||
"references": [ | ||
"https://www.w3.org/TR/css-lists-3/#counter-reset" | ||
], | ||
"syntax": "[ <counter-name> <integer>? ]+ | none" | ||
}, | ||
"counter-increment": { | ||
"comment": "<custom-ident> -> <counter-name>", | ||
"references": [ | ||
"https://www.w3.org/TR/css-lists-3/#propdef-counter-increment" | ||
], | ||
"syntax": "[ <counter-name> <integer>? ]+ | none" | ||
}, | ||
"counter-set": { | ||
"comment": "<custom-ident> -> <counter-name>", | ||
"references": [ | ||
"https://www.w3.org/TR/css-lists-3/#propdef-counter-set" | ||
], | ||
"syntax": "[ <counter-name> <integer>? ]+ | none" | ||
}, | ||
"cue": { | ||
@@ -296,12 +321,15 @@ "comment": "https://www.w3.org/TR/css3-speech/#property-index", | ||
"max-width": { | ||
"comment": "fix auto -> none (https://github.com/mdn/data/pull/431); extend by non-standard width keywords https://developer.mozilla.org/en-US/docs/Web/CSS/max-width", | ||
"syntax": "none | <length-percentage> | min-content | max-content | fit-content(<length-percentage>) | <-non-standard-width>" | ||
"comment": "extend by non-standard width keywords https://developer.mozilla.org/en-US/docs/Web/CSS/max-width", | ||
"syntax": "| <-non-standard-width>" | ||
}, | ||
"width": { | ||
"comment": "per spec fit-content should be a function, however browsers are supporting it as a keyword (https://github.com/csstree/stylelint-validator/issues/29)", | ||
"syntax": "| fit-content | -moz-fit-content | -webkit-fit-content" | ||
"references": [ | ||
"https://developer.mozilla.org/en-US/docs/Web/CSS/width", | ||
"https://github.com/csstree/stylelint-validator/issues/29" | ||
], | ||
"syntax": "| fill | stretch | intrinsic | -moz-max-content | -webkit-max-content | -moz-fit-content | -webkit-fit-content" | ||
}, | ||
"min-width": { | ||
"comment": "extend by non-standard width keywords https://developer.mozilla.org/en-US/docs/Web/CSS/width", | ||
"syntax": "auto | <length-percentage> | min-content | max-content | fit-content(<length-percentage>) | <-non-standard-width>" | ||
"syntax": "| <-non-standard-width>" | ||
}, | ||
@@ -593,5 +621,27 @@ "overflow": { | ||
"content-list": { | ||
"comment": "missed -> https://drafts.csswg.org/css-content/#typedef-content-list (document-url, <target> and leader() is omitted util stabilization)", | ||
"syntax": "[ <string> | contents | <image> | <quote> | <target> | <leader()> | <attr()> | counter( <ident>, <'list-style-type'>? ) ]+" | ||
"comment": "add missed <counter> -> https://drafts.csswg.org/css-content/#typedef-content-list", | ||
"syntax": "[ <string> | contents | <image> | <counter> | <quote> | <target> | <leader()> ]+" | ||
}, | ||
"counter": { | ||
"comment": "missed", | ||
"syntax": "<counter()> | <counters()>" | ||
}, | ||
"counter()": { | ||
"comment": "<custom-ident> -> <counter-name>", | ||
"references": [ | ||
"https://www.w3.org/TR/css-lists-3/#counter-functions" | ||
], | ||
"syntax": "counter( <counter-name>, <counter-style>? )" | ||
}, | ||
"counters()": { | ||
"comment": "<custom-ident> -> <counter-name>", | ||
"references": [ | ||
"https://www.w3.org/TR/css-lists-3/#counter-functions" | ||
], | ||
"syntax": "counters( <counter-name>, <string>, <counter-style>? )" | ||
}, | ||
"counter-name": { | ||
"comment": "missed", | ||
"syntax": "<custom-ident>" | ||
}, | ||
"element()": { | ||
@@ -598,0 +648,0 @@ "comment": "https://drafts.csswg.org/css-gcpm/#element-syntax & https://drafts.csswg.org/css-images-4/#element-notation", |
@@ -1,1 +0,1 @@ | ||
export const version = "2.0.0-dev"; | ||
export const version = "2.0.2"; |
import { createRequire } from 'module'; | ||
import patch from './data-patch.js'; | ||
@@ -7,3 +8,2 @@ const require = createRequire(import.meta.url); | ||
const mdnSyntaxes = require('mdn-data/css/syntaxes.json'); | ||
const patch = require('../data/patch.json'); | ||
@@ -10,0 +10,0 @@ const extendSyntax = /^\s*\|\s*/; |
@@ -1,2 +0,2 @@ | ||
import { SourceMapGenerator } from 'source-map/lib/source-map-generator.js'; | ||
import { SourceMapGenerator } from 'source-map-js/lib/source-map-generator.js'; | ||
@@ -3,0 +3,0 @@ const trackNodes = new Set(['Atrule', 'Selector', 'Declaration']); |
@@ -92,2 +92,3 @@ import { | ||
['#', Dimension], | ||
['#', CDC], // https://github.com/w3c/csswg-drafts/pull/6874 | ||
@@ -102,2 +103,3 @@ ['-', Ident], | ||
['-', Dimension], | ||
['-', CDC], // https://github.com/w3c/csswg-drafts/pull/6874 | ||
@@ -111,2 +113,4 @@ [NumberToken, Ident], | ||
[NumberToken, Dimension], | ||
[NumberToken, '%'], | ||
[NumberToken, CDC], // https://github.com/w3c/csswg-drafts/pull/6874 | ||
@@ -118,2 +122,3 @@ ['@', Ident], | ||
['@', '-'], | ||
['@', CDC], // https://github.com/w3c/csswg-drafts/pull/6874 | ||
@@ -130,3 +135,8 @@ ['.', NumberToken], | ||
]; | ||
// validate with scripts/generate-safe | ||
const safePairs = specPairs.concat([ | ||
[Ident, Hash], | ||
[Hash, Hash], | ||
[AtKeyword, LeftParenthesis], | ||
@@ -136,9 +146,13 @@ [AtKeyword, StringToken], | ||
[Percentage, Percentage], | ||
[Percentage, Dimension], | ||
[Percentage, FunctionToken], | ||
[Percentage, '-'], | ||
[RightParenthesis, Ident], | ||
[RightParenthesis, FunctionToken], | ||
[RightParenthesis, Url], | ||
[Url, Ident], | ||
[Url, FunctionToken], | ||
[Url, Url] | ||
[RightParenthesis, Percentage], | ||
[RightParenthesis, Dimension], | ||
[RightParenthesis, Hash], | ||
[RightParenthesis, '-'] | ||
]); | ||
@@ -154,5 +168,10 @@ | ||
const nextCharCode = value.charCodeAt(0); | ||
const emitWs = nextCharCode === HYPHENMINUS || nextCharCode === PLUSSIGN | ||
? isWhiteSpaceRequired.has(prevCode << 16 | nextCharCode << 8) | ||
: isWhiteSpaceRequired.has(prevCode << 16 | nextCode); | ||
const emitWs = | ||
(nextCharCode === HYPHENMINUS && | ||
type !== Ident && | ||
type !== FunctionToken && | ||
type !== CDC) || | ||
(nextCharCode === PLUSSIGN) | ||
? isWhiteSpaceRequired.has(prevCode << 16 | nextCharCode << 8) | ||
: isWhiteSpaceRequired.has(prevCode << 16 | nextCode); | ||
@@ -159,0 +178,0 @@ if (emitWs) { |
@@ -60,3 +60,3 @@ import anPlusB from './generic-an-plus-b.js'; | ||
// safe char code getter | ||
function charCode(str, index) { | ||
function charCodeAt(str, index) { | ||
return index < str.length ? str.charCodeAt(index) : 0; | ||
@@ -86,4 +86,4 @@ } | ||
return ( | ||
str.charCodeAt(offset) === 0x005C && // U+005C REVERSE SOLIDUS (\) | ||
isDigit(str.charCodeAt(offset + 1)) | ||
charCodeAt(str, offset) === 0x005C && // U+005C REVERSE SOLIDUS (\) | ||
isDigit(charCodeAt(str, offset + 1)) | ||
); | ||
@@ -133,2 +133,8 @@ } | ||
balanceCloseType = balanceStash.pop(); | ||
if (balanceStash.length === 0) { | ||
length++; | ||
break scan; | ||
} | ||
break; | ||
@@ -239,3 +245,3 @@ | ||
// ... that starts with two dashes (U+002D HYPHEN-MINUS) | ||
if (charCode(token.value, 0) !== 0x002D || charCode(token.value, 1) !== 0x002D) { | ||
if (charCodeAt(token.value, 0) !== 0x002D || charCodeAt(token.value, 1) !== 0x002D) { | ||
return 0; | ||
@@ -264,3 +270,3 @@ } | ||
for (let i = 1; i < length; i++) { | ||
if (!isHexDigit(token.value.charCodeAt(i))) { | ||
if (!isHexDigit(charCodeAt(token.value, i))) { | ||
return 0; | ||
@@ -278,3 +284,3 @@ } | ||
if (!isIdentifierStart(charCode(token.value, 1), charCode(token.value, 2), charCode(token.value, 3))) { | ||
if (!isIdentifierStart(charCodeAt(token.value, 1), charCodeAt(token.value, 2), charCodeAt(token.value, 3))) { | ||
return 0; | ||
@@ -514,8 +520,8 @@ } | ||
// The first digit of an integer may be immediately preceded by `-` or `+` to indicate the integer’s sign. | ||
let i = token.value.charCodeAt(0) === 0x002B || // U+002B PLUS SIGN (+) | ||
token.value.charCodeAt(0) === 0x002D ? 1 : 0; // U+002D HYPHEN-MINUS (-) | ||
let i = charCodeAt(token.value, 0) === 0x002B || // U+002B PLUS SIGN (+) | ||
charCodeAt(token.value, 0) === 0x002D ? 1 : 0; // U+002D HYPHEN-MINUS (-) | ||
// When written literally, an integer is one or more decimal digits 0 through 9 ... | ||
for (; i < token.value.length; i++) { | ||
if (!isDigit(token.value.charCodeAt(i))) { | ||
if (!isDigit(charCodeAt(token.value, i))) { | ||
return 0; | ||
@@ -522,0 +528,0 @@ } |
{ | ||
"name": "css-tree", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A tool set for CSS: fast detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations", | ||
@@ -53,2 +53,10 @@ "author": "Roman Dvornov <rdvornov@gmail.com> (https://github.com/lahmatiy)", | ||
}, | ||
"./definition-syntax-data": { | ||
"import": "./lib/data.js", | ||
"require": "./cjs/data.cjs" | ||
}, | ||
"./definition-syntax-data-patch": { | ||
"import": "./lib/data-patch.js", | ||
"require": "./cjs/data-patch.cjs" | ||
}, | ||
"./utils": { | ||
@@ -60,4 +68,4 @@ "import": "./lib/utils/index.js", | ||
"browser": { | ||
"./cjs/data.cjs": "./dist/data.js", | ||
"./cjs/version.cjs": "./dist/version.js", | ||
"./cjs/data.cjs": "./dist/data.cjs", | ||
"./cjs/version.cjs": "./dist/version.cjs", | ||
"./lib/data.js": "./dist/data.js", | ||
@@ -88,3 +96,3 @@ "./lib/version.js": "./dist/version.js" | ||
"mdn-data": "2.0.23", | ||
"source-map": "^0.6.1" | ||
"source-map-js": "^1.0.1" | ||
}, | ||
@@ -94,8 +102,7 @@ "devDependencies": { | ||
"clap": "^2.0.1", | ||
"coveralls": "^3.1.1", | ||
"esbuild": "^0.13.3", | ||
"eslint": "^7.24.0", | ||
"esbuild": "^0.14.1", | ||
"eslint": "^8.4.1", | ||
"json-to-ast": "^2.1.0", | ||
"mocha": "^9.1.2", | ||
"rollup": "^2.58.0" | ||
"rollup": "^2.60.2" | ||
}, | ||
@@ -102,0 +109,0 @@ "engines": { |
@@ -148,2 +148,4 @@ <img align="right" width="111" height="111" | ||
import * as definitionSyntax from 'css-tree/definition-syntax'; | ||
import * as data from 'css-tree/definition-syntax-data'; | ||
import * as dataPatch from 'css-tree/definition-syntax-data-patch'; | ||
import * as utils from 'css-tree/utils'; | ||
@@ -154,7 +156,7 @@ ``` | ||
There are bundles are available for using in a browser: | ||
Bundles are available for use in a browser: | ||
- `dist/csstree.js` – minified IIFE with `csstree` as global | ||
```html | ||
<script src="node_modules/css-tree/dist/csstreejs"></script> | ||
<script src="node_modules/css-tree/dist/csstree.js"></script> | ||
<script> | ||
@@ -161,0 +163,0 @@ csstree.parse('.example { color: green }'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1130949
7
231
21843
194
3
+ Addedsource-map-js@^1.0.1
+ Addedsource-map-js@1.2.0(transitive)
- Removedsource-map@^0.6.1
- Removedsource-map@0.6.1(transitive)