Merge branch 'master' of github.com:adamdruppe/arsd

This commit is contained in:
Adam D. Ruppe 2022-12-16 11:17:24 -05:00
commit 18cc05a34d
1 changed files with 285 additions and 272 deletions

15
dom.d
View File

@ -4173,13 +4173,26 @@ struct AttributeSet {
}
private Element _element;
///
/// Sets a `value` for `attribute`. If doens't exists, creates it
string set(string name, string value) {
_element.setAttribute(name, value);
return value;
}
/// Provides support for testing with `in`
auto opBinaryRight(string op : "in")(string name) const
{
return name in _element.attributes;
}
///
unittest
{
auto doc = new XmlDocument(`<test attr="test"/>`);
assert("attr" in doc.root.attrs);
assert("test" !in doc.root.attrs);
}
/// Returns attribute `name`, or `null` if doesn't exist
string get(string name) const {
return _element.getAttribute(name);
}