mirror of https://github.com/webpack/webpack.git
fix: bug with balanced parens
This commit is contained in:
parent
e3f83e2edc
commit
9d930f7a67
|
|
@ -399,12 +399,12 @@ class CssParser extends Parser {
|
|||
}
|
||||
default: {
|
||||
// TODO move escaped parsing to tokenizer
|
||||
const lastFunction = balanced[balanced.length - 1];
|
||||
const last = balanced[balanced.length - 1];
|
||||
|
||||
if (
|
||||
lastFunction &&
|
||||
(lastFunction[0].replace(/\\/g, "").toLowerCase() === "url" ||
|
||||
IMAGE_SET_FUNCTION.test(lastFunction[0].replace(/\\/g, "")))
|
||||
last &&
|
||||
(last[0].replace(/\\/g, "").toLowerCase() === "url" ||
|
||||
IMAGE_SET_FUNCTION.test(last[0].replace(/\\/g, "")))
|
||||
) {
|
||||
let value = normalizeUrl(input.slice(start + 1, end - 1), true);
|
||||
|
||||
|
|
@ -417,8 +417,7 @@ class CssParser extends Parser {
|
|||
break;
|
||||
}
|
||||
|
||||
const isUrl =
|
||||
lastFunction[0].replace(/\\/g, "").toLowerCase() === "url";
|
||||
const isUrl = last[0].replace(/\\/g, "").toLowerCase() === "url";
|
||||
const dep = new CssUrlDependency(
|
||||
value,
|
||||
[start, end],
|
||||
|
|
@ -677,7 +676,7 @@ class CssParser extends Parser {
|
|||
return end;
|
||||
},
|
||||
rightParenthesis: (input, start, end) => {
|
||||
const lastFunction = balanced[balanced.length - 1];
|
||||
const last = balanced[balanced.length - 1];
|
||||
|
||||
balanced.pop();
|
||||
|
||||
|
|
@ -695,21 +694,18 @@ class CssParser extends Parser {
|
|||
break;
|
||||
}
|
||||
case CSS_MODE_AT_IMPORT_EXPECT_URL: {
|
||||
if (lastFunction && lastFunction[0] === "url") {
|
||||
if (last && last[0] === "url") {
|
||||
modeData.lastPos = end;
|
||||
mode = CSS_MODE_AT_IMPORT_EXPECT_LAYER_OR_SUPPORTS_OR_MEDIA;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CSS_MODE_AT_IMPORT_EXPECT_LAYER_OR_SUPPORTS_OR_MEDIA: {
|
||||
if (lastFunction && lastFunction[0].toLowerCase() === "layer") {
|
||||
modeData.layer = input.slice(lastFunction[2], end - 1).trim();
|
||||
if (last && last[0].toLowerCase() === "layer") {
|
||||
modeData.layer = input.slice(last[2], end - 1).trim();
|
||||
modeData.lastPos = end;
|
||||
} else if (
|
||||
lastFunction &&
|
||||
lastFunction[0].toLowerCase() === "supports"
|
||||
) {
|
||||
modeData.supports = input.slice(lastFunction[2], end - 1).trim();
|
||||
} else if (last && last[0].toLowerCase() === "supports") {
|
||||
modeData.supports = input.slice(last[2], end - 1).trim();
|
||||
modeData.lastPos = end;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -173,6 +173,7 @@ url(style6.css?foo=5)
|
|||
@import url("./style8.css") (prefers-color-scheme: dark);
|
||||
@import url("./style8.css") supports(display: flex);
|
||||
@import url("./style8.css") supports(((display: flex)));
|
||||
@import url("./style8.css") supports(((display: inline-grid))) screen and (((min-width: 400px)));
|
||||
@import url("./style8.css") supports(display: flex);
|
||||
@import url('./style8.css') supports(display: grid);
|
||||
@import url("./style8.css") supports(display: flex) screen and (min-width: 400px);
|
||||
|
|
|
|||
Loading…
Reference in New Issue