From 3a8f47f4dba715d723d2390588bfd0f3716f628e Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 10 Nov 2020 20:32:50 +0300 Subject: [PATCH] revert d405bc64 - obsolete since stylus-lang 0.54.7 --- background/background-worker.js | 2 +- js/moz-parser.js | 13 ++----------- vendor-overwrites/csslint/parserlib.js | 6 ------ 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/background/background-worker.js b/background/background-worker.js index d1908b1c..2b49eebd 100644 --- a/background/background-worker.js +++ b/background/background-worker.js @@ -37,7 +37,7 @@ function compileUsercss(preprocessor, code, vars) { const builder = getUsercssCompiler(preprocessor); vars = simpleVars(vars); return Promise.resolve(builder.preprocess ? builder.preprocess(code, vars) : code) - .then(code => parseMozFormat({code, emptyDocument: preprocessor === 'stylus'})) + .then(code => parseMozFormat({code})) .then(({sections, errors}) => { if (builder.postprocess) { builder.postprocess(sections, vars); diff --git a/js/moz-parser.js b/js/moz-parser.js index 6ffb3b67..d79c4789 100644 --- a/js/moz-parser.js +++ b/js/moz-parser.js @@ -7,12 +7,10 @@ * Puts the global comments into the following section to minimize the amount of global sections. * Doesn't move the comment with ==UserStyle== inside. * @param {string} code - * @param {boolean} emptyDocument - https://github.com/stylus/stylus/issues/2415, - * TODO: update stylus-lang and remove emptyDocument everywhere * @param {number} styleId - used to preserve parserCache on subsequent runs over the same style * @returns {{sections: Array, errors: Array}} */ -function parseMozFormat({code, emptyDocument, styleId}) { +function parseMozFormat({code, styleId}) { const CssToProperty = { 'url': 'urls', 'url-prefix': 'urlPrefixes', @@ -20,7 +18,7 @@ function parseMozFormat({code, emptyDocument, styleId}) { 'regexp': 'regexps', }; const hasSingleEscapes = /([^\\]|^)\\([^\\]|$)/; - const parser = new parserlib.css.Parser({starHack: true, emptyDocument}); + const parser = new parserlib.css.Parser({starHack: true}); const sectionStack = [{code: '', start: 0}]; const errors = []; const sections = []; @@ -72,13 +70,6 @@ function parseMozFormat({code, emptyDocument, styleId}) { doAddSection(section); }); - parser.addListener('emptydocument', e => { - const token = parser._tokenStream._token; - const section = sectionStack[sectionStack.length - 1]; - section.code += mozStyle.slice(section.start, e.offset); - section.start = token.offset + token.value.length; - }); - parser.addListener('endstylesheet', () => { // add nonclosed outer sections (either broken or the last global one) const lastSection = sectionStack[sectionStack.length - 1]; diff --git a/vendor-overwrites/csslint/parserlib.js b/vendor-overwrites/csslint/parserlib.js index 4003e3c2..c364f72b 100644 --- a/vendor-overwrites/csslint/parserlib.js +++ b/vendor-overwrites/csslint/parserlib.js @@ -4006,7 +4006,6 @@ self.parserlib = (() => { * @param {Boolean} [options.starHack] - allows IE6 star hack * @param {Boolean} [options.underscoreHack] - interprets leading underscores as IE6-7 for known properties * @param {Boolean} [options.ieFilters] - accepts IE < 8 filters instead of throwing syntax errors - * @param {Boolean} [options.emptyDocument] - accepts @document without {} block produced by stylus-lang */ constructor(options) { super(); @@ -4437,11 +4436,6 @@ self.parserlib = (() => { this._ws(); functions.push(this._documentFunction() || stream.LT(1)); } while (stream.match(Tokens.COMMA)); - this._ws(); - if (this.options.emptyDocument && stream.peek() !== Tokens.LBRACE) { - this.fire({type: 'emptydocument', functions, prefix}, start); - return; - } for (const fn of functions) { if ((fn.type !== 'function' || !/^(url(-prefix)?|domain|regexp)$/i.test(fn.name)) && fn.type !== 'uri') {