Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.

Commit 4972aeb

Browse files
committed
line number for AtRule should be the number of its identifier
1 parent 6e65e00 commit 4972aeb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/Sabberworm/CSS/Parser.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ private function parseListItem(CSSList $oList, $bIsRoot = false) {
132132
private function parseAtRule() {
133133
$this->consume('@');
134134
$sIdentifier = $this->parseIdentifier();
135+
$iIdentifierLineNum = $this->iLineNum;
135136
$this->consumeWhiteSpace();
136137
if ($sIdentifier === 'import') {
137138
$oLocation = $this->parseURLValue();
@@ -141,14 +142,14 @@ private function parseAtRule() {
141142
$sMediaQuery = $this->consumeUntil(';');
142143
}
143144
$this->consume(';');
144-
return new Import($oLocation, $sMediaQuery, $this->iLineNum);
145+
return new Import($oLocation, $sMediaQuery, $iIdentifierLineNum);
145146
} else if ($sIdentifier === 'charset') {
146147
$sCharset = $this->parseStringValue();
147148
$this->consumeWhiteSpace();
148149
$this->consume(';');
149-
return new Charset($sCharset, $this->iLineNum);
150+
return new Charset($sCharset, $iIdentifierLineNum);
150151
} else if ($this->identifierIs($sIdentifier, 'keyframes')) {
151-
$oResult = new KeyFrame($this->iLineNum);
152+
$oResult = new KeyFrame($iIdentifierLineNum);
152153
$oResult->setVendorKeyFrame($sIdentifier);
153154
$oResult->setAnimationName(trim($this->consumeUntil('{', false, true)));
154155
$this->consumeWhiteSpace();
@@ -168,7 +169,7 @@ private function parseAtRule() {
168169
if (!($mUrl instanceof CSSString || $mUrl instanceof URL)) {
169170
throw new UnexpectedTokenException('Wrong namespace url of invalid type', $mUrl, 'custom');
170171
}
171-
return new CSSNamespace($mUrl, $sPrefix, $this->iLineNum);
172+
return new CSSNamespace($mUrl, $sPrefix, $iIdentifierLineNum);
172173
} else {
173174
//Unknown other at rule (font-face or such)
174175
$sArgs = trim($this->consumeUntil('{', false, true));
@@ -181,10 +182,10 @@ private function parseAtRule() {
181182
}
182183
}
183184
if($bUseRuleSet) {
184-
$oAtRule = new AtRuleSet($sIdentifier, $sArgs, $this->iLineNum);
185+
$oAtRule = new AtRuleSet($sIdentifier, $sArgs, $iIdentifierLineNum);
185186
$this->parseRuleSet($oAtRule);
186187
} else {
187-
$oAtRule = new AtRuleBlockList($sIdentifier, $sArgs, $this->iLineNum);
188+
$oAtRule = new AtRuleBlockList($sIdentifier, $sArgs, $iIdentifierLineNum);
188189
$this->parseList($oAtRule);
189190
}
190191
return $oAtRule;

0 commit comments

Comments
 (0)