Fixed: Invalid pseudo element selector match
--HG-- branch : develop
This commit is contained in:
parent
077f57c4b9
commit
5ac0279754
3 changed files with 44 additions and 12 deletions
|
@ -84,6 +84,9 @@ namespace NLGUI
|
|||
// NOTE: Does not check combinator
|
||||
bool match(const CHtmlElement &elm) const;
|
||||
|
||||
// debug
|
||||
std::string toString() const;
|
||||
|
||||
private:
|
||||
bool matchClass(const CHtmlElement &elm) const;
|
||||
bool matchAttributes(const CHtmlElement &elm) const;
|
||||
|
|
|
@ -631,18 +631,9 @@ namespace NLGUI
|
|||
{
|
||||
result.clear();
|
||||
}
|
||||
else if (result.empty() || !current.empty())
|
||||
else if (!current.empty())
|
||||
{
|
||||
// pseudo element like ':before' can only be set on the last selector
|
||||
if (!result.empty() && !pseudoElement.empty())
|
||||
{
|
||||
// failed
|
||||
result.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
result.push_back(current);
|
||||
}
|
||||
result.push_back(current);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -310,5 +310,43 @@ namespace NLGUI
|
|||
}
|
||||
}
|
||||
|
||||
std::string CCssSelector::toString() const
|
||||
{
|
||||
std::string ret;
|
||||
ret += Element;
|
||||
ret += Id;
|
||||
if (!Class.empty())
|
||||
{
|
||||
for(uint i = 0; i<Class.size(); i++)
|
||||
ret += "." + Class[i];
|
||||
}
|
||||
if (!Attr.empty())
|
||||
{
|
||||
for(uint i = 0; i<Attr.size(); ++i)
|
||||
{
|
||||
ret += "[" + Attr[i].key;
|
||||
if (Attr[i].op != ' ')
|
||||
{
|
||||
ret += Attr[i].op + Attr[i].value;
|
||||
}
|
||||
ret += "]";
|
||||
}
|
||||
}
|
||||
if (!PseudoClass.empty())
|
||||
{
|
||||
for(uint i = 0; i<PseudoClass.size(); ++i)
|
||||
{
|
||||
ret += ":" + PseudoClass[i];
|
||||
}
|
||||
}
|
||||
if (Combinator != '\0')
|
||||
{
|
||||
ret += Combinator;
|
||||
}
|
||||
|
||||
// ret += ":" + PseudoClass;
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
Loading…
Reference in a new issue