Skip to content

Commit

Permalink
Introduce ability to append single element and get exact tag type as …
Browse files Browse the repository at this point in the history
…result
  • Loading branch information
Sergey Mashkov committed May 5, 2015
1 parent 4bfcf67 commit 04680c4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions js/src/main/kotlin/dom.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package html4k.dom

import html4k.*
import html4k.js.*
import html4k.consumers.onFinalize
import html4k.consumers.onFinalizeMap
import org.w3c.dom.Node
Expand Down Expand Up @@ -83,3 +84,6 @@ public fun Node.append(block : TagConsumer<HTMLElement>.() -> Unit) : List<HTMLE

result
}

public val HTMLElement.append : TagConsumer<HTMLElement>
get() = (ownerDocument as HTMLDocument).createTree().onFinalize { element, partial -> if (!partial) { this@append.appendChild(element) } }

0 comments on commit 04680c4

Please sign in to comment.