pulse-js-framework 1.7.20 → 1.7.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/parser.js +22 -10
- package/package.json +1 -1
package/compiler/parser.js
CHANGED
|
@@ -1682,13 +1682,14 @@ export class Parser {
|
|
|
1682
1682
|
|
|
1683
1683
|
// Tokens that should not have space after them in CSS values
|
|
1684
1684
|
const noSpaceAfter = new Set(['#', '(', '.', '/', 'rgba', 'rgb', 'hsl', 'hsla', 'var', 'calc', 'url', 'linear-gradient', 'radial-gradient']);
|
|
1685
|
-
// Tokens that should not have space before them
|
|
1686
|
-
const noSpaceBefore = new Set([')', ',', '%', 'px', 'em', 'rem', 'vh', 'vw', 'fr', 's', 'ms', '(']);
|
|
1685
|
+
// Tokens that should not have space before them (units and punctuation)
|
|
1686
|
+
const noSpaceBefore = new Set([')', ',', '%', 'px', 'em', 'rem', 'vh', 'vw', 'vmin', 'vmax', 'fr', 's', 'ms', '(', 'deg', 'rad', 'turn', 'grad', 'ex', 'ch', 'pt', 'pc', 'in', 'cm', 'mm']);
|
|
1687
1687
|
|
|
1688
1688
|
let value = '';
|
|
1689
1689
|
let lastTokenValue = '';
|
|
1690
1690
|
let lastTokenLine = this.current()?.line || 0;
|
|
1691
1691
|
let afterHash = false; // Track if we're collecting a hex color
|
|
1692
|
+
let hexColorLength = 0; // Track hex color length (max 8 for RRGGBBAA)
|
|
1692
1693
|
let inCssVar = false; // Track if we're inside var(--...)
|
|
1693
1694
|
|
|
1694
1695
|
while (!this.is(TokenType.SEMICOLON) && !this.is(TokenType.RBRACE) && !this.is(TokenType.EOF)) {
|
|
@@ -1713,12 +1714,24 @@ export class Parser {
|
|
|
1713
1714
|
}
|
|
1714
1715
|
|
|
1715
1716
|
// For hex colors (#abc123), collect tokens without spacing after #
|
|
1717
|
+
// Hex colors are 3, 4, 6, or 8 characters long
|
|
1716
1718
|
if (tokenValue === '#') {
|
|
1717
1719
|
afterHash = true;
|
|
1720
|
+
hexColorLength = 0;
|
|
1718
1721
|
} else if (afterHash) {
|
|
1719
|
-
//
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
+
// Check if this token is a valid hex color continuation
|
|
1723
|
+
const tokenStr = String(tokenValue);
|
|
1724
|
+
const isHexChar = /^[0-9a-fA-F]+$/.test(tokenStr);
|
|
1725
|
+
if (isHexChar) {
|
|
1726
|
+
const newLength = hexColorLength + tokenStr.length;
|
|
1727
|
+
// Valid hex color lengths are 3, 4, 6, or 8
|
|
1728
|
+
// If adding this token would exceed a valid length, stop
|
|
1729
|
+
if (hexColorLength >= 6 || newLength > 8) {
|
|
1730
|
+
afterHash = false;
|
|
1731
|
+
} else {
|
|
1732
|
+
hexColorLength = newLength;
|
|
1733
|
+
}
|
|
1734
|
+
} else {
|
|
1722
1735
|
afterHash = false;
|
|
1723
1736
|
}
|
|
1724
1737
|
}
|
|
@@ -1727,16 +1740,15 @@ export class Parser {
|
|
|
1727
1740
|
// - It's the first token
|
|
1728
1741
|
// - Last token was in noSpaceAfter
|
|
1729
1742
|
// - This token is in noSpaceBefore
|
|
1730
|
-
// - We're collecting a hex color (afterHash
|
|
1743
|
+
// - We're collecting a hex color (afterHash is true)
|
|
1731
1744
|
// - We're inside var(--...) and this is part of the variable name
|
|
1732
1745
|
// - Last was '-' and current is an identifier (hyphenated name)
|
|
1733
|
-
const skipSpace = noSpaceAfter.has(lastTokenValue) ||
|
|
1746
|
+
const skipSpace = noSpaceAfter.has(String(lastTokenValue)) ||
|
|
1734
1747
|
noSpaceBefore.has(tokenValue) ||
|
|
1735
|
-
|
|
1736
|
-
(afterHash && /^[0-9a-fA-F]+$/.test(tokenValue)) ||
|
|
1748
|
+
afterHash ||
|
|
1737
1749
|
inCssVar ||
|
|
1738
1750
|
(lastTokenValue === '-' || lastTokenValue === '--') ||
|
|
1739
|
-
(tokenValue === '-' && /^[a-zA-Z]/.test(this.current()?.value || ''));
|
|
1751
|
+
(tokenValue === '-' && /^[a-zA-Z]/.test(String(this.current()?.value || '')));
|
|
1740
1752
|
|
|
1741
1753
|
if (value.length > 0 && !skipSpace) {
|
|
1742
1754
|
value += ' ';
|