parserlib: handle layer statements anywhere

This commit is contained in:
tophf 2022-02-12 01:18:03 +03:00
parent 81a5acfda3
commit 648b295ef2

View File

@ -3478,7 +3478,10 @@ self.parserlib = (() => {
} }
if ((val = t.value) === '{') { if ((val = t.value) === '{') {
if (ids[1]) this.fire({type: 'error', message: '@layer block cannot have multiple ids'}, start); if (ids[1]) this.fire({type: 'error', message: '@layer block cannot have multiple ids'}, start);
this._layerBlock(start, true, ids[0]); this.fire({type: 'startlayer', id: ids[0] || null}, start);
this._rulesetBlock(start);
this.fire('endlayer');
this._ws();
return; return;
} }
} while (val === ','); } while (val === ',');
@ -3487,18 +3490,6 @@ self.parserlib = (() => {
this._ws(); this._ws();
} }
_layerBlock(start, inBlock, id) {
if (!inBlock) {
this._ws();
id = this._tokenStream.match(Tokens.IDENT);
this._tokenStream.mustMatch(Tokens.LBRACE);
}
this.fire({type: 'startlayer', id: id || null}, start);
this._rulesetBlock(start);
this.fire('endlayer');
this._ws();
}
_stylesheet() { _stylesheet() {
const stream = this._tokenStream; const stream = this._tokenStream;
this.fire('startstylesheet'); this.fire('startstylesheet');
@ -4586,7 +4577,7 @@ self.parserlib = (() => {
[Tokens.DOCUMENT_SYM]: Parser.prototype._documentMisplaced, [Tokens.DOCUMENT_SYM]: Parser.prototype._documentMisplaced,
[Tokens.FONT_FACE_SYM]: Parser.prototype._fontFace, [Tokens.FONT_FACE_SYM]: Parser.prototype._fontFace,
[Tokens.KEYFRAMES_SYM]: Parser.prototype._keyframes, [Tokens.KEYFRAMES_SYM]: Parser.prototype._keyframes,
[Tokens.LAYER_SYM]: Parser.prototype._layerBlock, [Tokens.LAYER_SYM]: Parser.prototype._layer,
[Tokens.MEDIA_SYM]: Parser.prototype._media, [Tokens.MEDIA_SYM]: Parser.prototype._media,
[Tokens.PAGE_SYM]: Parser.prototype._page, [Tokens.PAGE_SYM]: Parser.prototype._page,
[Tokens.SUPPORTS_SYM]: Parser.prototype._supports, [Tokens.SUPPORTS_SYM]: Parser.prototype._supports,