|
1 | 1 | //[parsed_css] |
2 | 2 |
|
| 3 | +/* eslint-disable no-cond-assign */ |
3 | 4 | try { |
4 | 5 | const MAX_STYLESHEET_BYTES = 500 * 1024; // 500 KB |
5 | 6 | const MAX_AST_BYTES = 4 * 1024 * 1024; // 4 MB |
|
8 | 9 | const block = Array.from(document.querySelectorAll('style')).map(i => ({url: 'block', body: i.innerHTML})); |
9 | 10 | const inline = Array.from(document.querySelectorAll('[style]')).map(i => ({url: 'inline', body: i.getAttribute('style')})); |
10 | 11 |
|
11 | | - const parsed_css = stylesheets.concat(block, inline).filter(({url, body}) => { |
| 12 | + const parsed_css = stylesheets.concat(block, inline).filter(({body}) => { |
12 | 13 | return body.length <= MAX_STYLESHEET_BYTES; |
13 | 14 | }).map(({url, body}) => { |
14 | 15 | return { |
|
18 | 19 | inline: url == 'inline' |
19 | 20 | }) |
20 | 21 | }; |
21 | | - }).filter(({url, ast}) => { |
| 22 | + }).filter(({ast}) => { |
22 | 23 | return JSON.stringify(ast).length <= MAX_AST_BYTES; |
23 | 24 | }); |
24 | 25 |
|
|
35 | 36 |
|
36 | 37 | // http://www.w3.org/TR/CSS21/grammar.html |
37 | 38 | // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027 |
| 39 | +/* eslint-disable-next-line no-unreachable */ |
38 | 40 | var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g |
39 | 41 |
|
40 | 42 | function parse(css, options){ |
@@ -64,7 +66,7 @@ function parse(css, options){ |
64 | 66 | */ |
65 | 67 |
|
66 | 68 | function position() { |
67 | | - var start = { line: lineno, column: column }; |
| 69 | + //var start = { line: lineno, column: column }; |
68 | 70 | return function(node){ |
69 | 71 | //node.position = new Position(start); |
70 | 72 | whitespace(); |
@@ -252,15 +254,15 @@ function parse(css, options){ |
252 | 254 | var pos = position(); |
253 | 255 |
|
254 | 256 | // prop |
255 | | - var prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/); |
| 257 | + var prop = match(/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/); |
256 | 258 | if (!prop) return; |
257 | 259 | prop = trim(prop[0]); |
258 | 260 |
|
259 | 261 | // : |
260 | 262 | if (!match(/^:\s*/)) return error("property missing ':'"); |
261 | 263 |
|
262 | 264 | // val |
263 | | - var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); |
| 265 | + var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/); |
264 | 266 |
|
265 | 267 | var ret = pos({ |
266 | 268 | type: 'declaration', |
@@ -332,7 +334,7 @@ function parse(css, options){ |
332 | 334 | var vendor = m[1]; |
333 | 335 |
|
334 | 336 | // identifier |
335 | | - var m = match(/^([-\w]+)\s*/); |
| 337 | + m = match(/^([-\w]+)\s*/); |
336 | 338 | if (!m) return error("@keyframes missing name"); |
337 | 339 | var name = m[1]; |
338 | 340 |
|
|
0 commit comments