Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support CSS variables #81

Merged
merged 2 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/CssLint/Linter.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,15 @@ protected function lintPropertyNameChar(string $sChar): ?bool
}

if ($sChar === ':') {
// Check if property name exists
$sPropertyName = trim($this->getContextContent());

// Ignore CSS variables (names starting with --)
if (substr($sPropertyName, 0, 2) === '--') {
$this->setContext(self::CONTEXT_PROPERTY_CONTENT);
return true;
}

// Check if property name exists
if (!$this->getCssLintProperties()->propertyExists($sPropertyName)) {
$this->addError('Unknown CSS property "' . $sPropertyName . '"');
}
Expand Down
7 changes: 6 additions & 1 deletion tests/_files/valid.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.button.drodown::after {
:root {
--border-radius: 3px;
}

.button.dropdown::after {
display: block;
width: 0;
height: 0;
Expand All @@ -7,6 +11,7 @@
border-bottom-width: 0;
border-top-style: solid;
border-color: #fefefe transparent transparent;
border-radius: var(--border-radius);
position: relative;
top: 0.4em;
display: inline-block;
Expand Down