Skip to content

Commit f8565c1

Browse files
sevenryzesonofmagic
authored andcommitted
To modify the "1" matched in the regular expression to match all integers and decimals in Infinite issue
The original regex is designed to match patterns like calc(infinity * 1px) or calc(infinity * 1rpx). When using a custom design width (e.g., 390 design units), Taro automatically calculates the ratio relative to the standard mini-program design width of 750. This results in formats like calc(infinite * 1.91rpx). However, the original regular expression can only handle scenarios with the 750 design width, causing the rounded-full replacement to fail. It is now proposed to modify the regex to match all numeric cases, thereby expanding the range of applicable scenarios. * (\d+\.?\d*|\.\d+) is used to match integers or decimals: * \d+\.?\d* : Matches integers with one or more digits, which can be followed by a decimal point and zero or more decimal digits (e.g., 1, 1., 1.2). * |\.\d+ : Alternatively, matches pure decimals starting with a decimal point (e.g., .5). This regular expression can match the following formats: * calc(infinity * 5px) * calc(infinity * 3.14rpx) * calc(infinity * .6px) * calc(infinity * 100.px)
1 parent 0316c6d commit f8565c1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • packages/postcss/src/plugins

packages/postcss/src/plugins/post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const postcssWeappTailwindcssPostPlugin: PostcssWeappTailwindcssRenamePlugin = (
4949
* @description 移除 calc(infinity * 1px)
5050
* https://github.com/tailwindlabs/tailwindcss/blob/77b3cb5318840925d8a75a11cc90552a93507ddc/packages/tailwindcss/src/utilities.ts#L2128
5151
*/
52-
else if (/calc\(\s*infinity\s*\*\s*1r?px/.test(decl.value)) {
52+
else if (/calc\(\s*infinity\s*\*\s*(\d+\.?\d*|\.\d+)r?px/.test(decl.value)) {
5353
decl.value = '9999px'
5454
}
5555
}

0 commit comments

Comments
 (0)