| 594 | } |
| 595 | |
| 596 | export function parseAtRule(buffer: string, nodes: AstNode[] = []): AtRule { |
| 597 | let name = buffer |
| 598 | let params = class="st">'' |
| 599 | |
| 600 | class="cm">// Assumption: The smallest at-rule in CSS right now is `@page`, this means |
| 601 | class="cm">// that we can always skip the first 5 characters and start at the |
| 602 | class="cm">// sixth (at index 5). |
| 603 | class="cm">// |
| 604 | class="cm">// There is a chance someone is using a shorter at-rule, in that case we have |
| 605 | class="cm">// to adjust this number back to 2, e.g.: `@x`. |
| 606 | class="cm">// |
| 607 | class="cm">// This issue can only occur if somebody does the following things: |
| 608 | class="cm">// |
| 609 | class="cm">// 1. Uses a shorter at-rule than `@page` |
| 610 | class="cm">// 2. Disables Lightning CSS from `@tailwindcss/postcss` (because Lightning |
| 611 | class="cm">// CSS doesn't handle custom at-rules properly right now) |
| 612 | class="cm">// 3. Sandwiches the `@tailwindcss/postcss` plugin between two other plugins |
| 613 | class="cm">// that can handle the shorter at-rule |
| 614 | class="cm">// |
| 615 | class="cm">// Let's use the more common case as the default and we can adjust this |
| 616 | class="cm">// behavior if necessary. |
| 617 | for (let i = 5 /* class="st">'@page'.length */; i < buffer.length; i++) { |
| 618 | let currentChar = buffer.charCodeAt(i) |
| 619 | if (currentChar === SPACE || currentChar === TAB || currentChar === OPEN_PAREN) { |
| 620 | name = buffer.slice(0, i) |
| 621 | params = buffer.slice(i) |
| 622 | break |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | return atRule(name.trim(), params.trim(), nodes) |
| 627 | } |
| 628 | |
| 629 | function parseDeclaration( |
| 630 | buffer: string, |