mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 11:15:24 +03:00
Merge pull request #653 from pulsar-edit/fix-style-manager-regex
[core]: Transforming Deprecated Math Usage - Support for Variables
This commit is contained in:
commit
f90d9bfdf8
@ -225,6 +225,26 @@ describe('StyleManager', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('recognizes valid less variables: right side', () => {
|
||||
let upgradedSheet = mathStyleManager.upgradeDeprecatedMathUsageForStyleSheet(
|
||||
"p { padding: @size + 12px; }",
|
||||
{}
|
||||
);
|
||||
expect(upgradedSheet.source).toEqual(
|
||||
"p { padding: calc(@size + 12px); }"
|
||||
);
|
||||
});
|
||||
|
||||
it('recognizes valid less variables: left side', () => {
|
||||
let upgradedSheet = mathStyleManager.upgradeDeprecatedMathUsageForStyleSheet(
|
||||
"p { padding: 12px + @size; }",
|
||||
{}
|
||||
);
|
||||
expect(upgradedSheet.source).toEqual(
|
||||
"p { padding: calc(12px + @size); }"
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when a sourcePath parameter is specified', () => {
|
||||
|
@ -437,7 +437,7 @@ function transformDeprecatedMathUsage(css, context) {
|
||||
const cssValueIgnoreList = /hsl|abs|acos|asin|atan|atan2|cos|mod|rem|sign|sin|tan|url/g;
|
||||
|
||||
const mathExpressionRegex =
|
||||
/-*(\d(\.\d)?)+(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|rlh|vw|vh|vmin|vmax|vb|vi|svw|svh|lvw|lvh|dvw|dvh|%)?(\s*([\/\+\*]|(\-\s+))\s*(\d(\.\d)*)+(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|rlh|vw|vh|vmin|vmax|vb|vi|svw|svh|lvw|lvh|dvw|dvh|%)?)+/g;
|
||||
/(-*(\d(\.\d)?)+(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|rlh|vw|vh|vmin|vmax|vb|vi|svw|svh|lvw|lvh|dvw|dvh|%)?|@?[\w-]+)(\s*([\/\+\*]|(\-\s+))\s*((\d(\.\d)*)+(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|rlh|vw|vh|vmin|vmax|vb|vi|svw|svh|lvw|lvh|dvw|dvh|%)?|@?[\w-]+))+/g;
|
||||
|
||||
try {
|
||||
transformedSource = postcss.parse(css);
|
||||
|
Loading…
Reference in New Issue
Block a user