fixed up the attribute helper method

This commit is contained in:
James Strachan
2012-02-29 09:07:59 +00:00
parent ed5e61911e
commit 84f4783192
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -190,9 +190,9 @@ fun Element.get(selector: String): List<Element> {
}
}
/** Returns the attribute value or null if its not present */
inline fun Element?.attribute(name: String): String? {
return this?.getAttribute(name)
/** Returns the attribute value or empty string if its not present */
inline fun Element.attribute(name: String): String {
return this.getAttribute(name) ?: ""
}
/** Returns the children of the element as a list */
+1 -1
View File
@@ -89,7 +89,7 @@ class DomBuilderTest() : TestSupport() {
if (grandChild != null) {
println("got element ${grandChild.toXmlString()} with text '${grandChild.text}`")
assertEquals("Hello World!", grandChild.text)
assertEquals(" bar tiny", grandChild.attribute("class") ?: "")
assertEquals(" bar tiny", grandChild.attribute("class"))
// test the classSet
val classSet = grandChild.classSet