1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

LibHTML: Basic element attribute parsing.

This commit is contained in:
Andreas Kling 2019-06-15 21:08:36 +02:00
parent 581d6b00c8
commit f8a86b5164
5 changed files with 194 additions and 17 deletions

View file

@ -11,6 +11,11 @@ public:
{
}
const String& name() const { return m_name; }
const String& value() const { return m_value; }
void set_value(const String& value) { m_value = value; }
private:
String m_name;
String m_value;
@ -23,7 +28,22 @@ public:
const String& tag_name() const { return m_tag_name; }
String attribute(const String& name) const;
void set_attribute(const String& name, const String& value);
void set_attributes(Vector<Attribute>&&);
template<typename Callback>
void for_each_attribute(Callback callback)
{
for (auto& attribute : m_attributes)
callback(attribute.name(), attribute.value());
}
private:
Attribute* find_attribute(const String& name);
const Attribute* find_attribute(const String& name) const;
String m_tag_name;
Vector<Attribute> m_attributes;
};