fixed up the attribute helper method
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user