Skip to content

Commit 2cdbfab

Browse files
authored
Merge pull request #257 from Randalphwa/first-of-type_bug
Fix infinite loop, specificity bug
2 parents 27d2482 + 021ab7e commit 2cdbfab

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

source/svgparser.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static bool matchPseudoClassSelector(const PseudoClassSelector& selector, const
214214
while(sibling) {
215215
if(sibling->id() == element->id())
216216
return false;
217-
sibling = element->previousElement();
217+
sibling = sibling->previousElement();
218218
}
219219

220220
return true;
@@ -225,7 +225,7 @@ static bool matchPseudoClassSelector(const PseudoClassSelector& selector, const
225225
while(sibling) {
226226
if(sibling->id() == element->id())
227227
return false;
228-
sibling = element->nextElement();
228+
sibling = sibling->nextElement();
229229
}
230230

231231
return true;
@@ -571,6 +571,9 @@ static RuleDataList parseStyleSheet(std::string_view input)
571571
for(const auto& attributeSelector : simpleSelector.attributeSelectors) {
572572
specificity += (attributeSelector.id == PropertyID::Id) ? 0x10000 : 0x100;
573573
}
574+
for(const auto& pseudoClassSelector : simpleSelector.pseudoClassSelectors) {
575+
specificity += 0x100;
576+
}
574577
}
575578

576579
rules.emplace_back(selector, rule.declarations, specificity, rules.size());

0 commit comments

Comments
 (0)