From 6d04c0eb7d017164e7277ad96f9c949bdff52106 Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 25 Nov 2020 21:01:36 +0300 Subject: [PATCH] optimize parserlib by ~10% * add skipValidation option * set `recoverable:true` on errors inside declarations --- js/moz-parser.js | 2 +- vendor-overwrites/csslint/parserlib.js | 4808 ++++++++++-------------- 2 files changed, 1980 insertions(+), 2830 deletions(-) diff --git a/js/moz-parser.js b/js/moz-parser.js index 8d6d2a31..f7a87016 100644 --- a/js/moz-parser.js +++ b/js/moz-parser.js @@ -18,7 +18,7 @@ function parseMozFormat({code, styleId}) { 'regexp': 'regexps', }; const hasSingleEscapes = /([^\\]|^)\\([^\\]|$)/; - const parser = new parserlib.css.Parser({starHack: true}); + const parser = new parserlib.css.Parser({starHack: true, skipValidation: true}); const sectionStack = [{code: '', start: 0}]; const errors = []; const sections = []; diff --git a/vendor-overwrites/csslint/parserlib.js b/vendor-overwrites/csslint/parserlib.js index 6618d4a3..11a2889c 100644 --- a/vendor-overwrites/csslint/parserlib.js +++ b/vendor-overwrites/csslint/parserlib.js @@ -28,85 +28,30 @@ THE SOFTWARE. self.parserlib = (() => { - //region Types - - const TYPES = { - DEFAULT_TYPE: 0, - COMBINATOR_TYPE: 1, - MEDIA_FEATURE_TYPE: 2, - MEDIA_QUERY_TYPE: 3, - PROPERTY_NAME_TYPE: 4, - PROPERTY_VALUE_TYPE: 5, - PROPERTY_VALUE_PART_TYPE: 6, - SELECTOR_TYPE: 7, - SELECTOR_PART_TYPE: 8, - SELECTOR_SUB_PART_TYPE: 9, - }; - - const UNITS = { - em: 'length', - rem: 'length', - ex: 'length', - px: 'length', - cm: 'length', - mm: 'length', - in: 'length', - pt: 'length', - pc: 'length', - ch: 'length', - vh: 'length', - vw: 'length', - vmax: 'length', - vmin: 'length', - fr: 'length', - q: 'length', - - deg: 'angle', - rad: 'angle', - grad: 'angle', - turn: 'angle', - - ms: 'time', - s: 'time', - - hz: 'frequency', - khz: 'frequency', - - dpi: 'resolution', - dpcm: 'resolution', - dppx: 'resolution', - x: 'resolution', - - ar: 'dimension', - }; - - //endregion - //region Properties + //#region Properties const Properties = { - // A - 'align-items': 'normal | stretch | | [ ? ]', - 'align-content': '', - 'align-self': '', - 'all': 'initial | inherit | unset', - 'alignment-adjust': 'auto | baseline | before-edge | text-before-edge | middle | central | ' + - 'after-edge | text-after-edge | ideographic | alphabetic | hanging | ' + - 'mathematical | | ', - 'alignment-baseline': 'auto | baseline | use-script | before-edge | text-before-edge | ' + - 'after-edge | text-after-edge | central | middle | ideographic | alphabetic | ' + - 'hanging | mathematical', - 'animation': '[