mirror of https://github.com/adamdruppe/arsd.git
Merge branch 'master' of github.com:adamdruppe/arsd
This commit is contained in:
commit
18cc05a34d
15
dom.d
15
dom.d
|
@ -4173,13 +4173,26 @@ struct AttributeSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Element _element;
|
private Element _element;
|
||||||
///
|
/// Sets a `value` for `attribute`. If doens't exists, creates it
|
||||||
string set(string name, string value) {
|
string set(string name, string value) {
|
||||||
_element.setAttribute(name, value);
|
_element.setAttribute(name, value);
|
||||||
return 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 {
|
string get(string name) const {
|
||||||
return _element.getAttribute(name);
|
return _element.getAttribute(name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue