Fix currentKomponent call
This commit is contained in:
@@ -6,9 +6,9 @@ import org.w3c.dom.Element
|
|||||||
import org.w3c.dom.HTMLElement
|
import org.w3c.dom.HTMLElement
|
||||||
import org.w3c.dom.get
|
import org.w3c.dom.get
|
||||||
|
|
||||||
private var currentKomponent: Komponent? = null
|
private val currentKomponents: MutableList<Komponent> = mutableListOf()
|
||||||
fun FlowOrMetaDataOrPhrasingContent.currentKomponent(): Komponent =
|
fun FlowOrMetaDataOrPhrasingContent.currentKomponent(): Komponent =
|
||||||
currentKomponent ?: error("No current komponent defined! Only call from render code!")
|
currentKomponents.lastOrNull() ?: error("No current komponent defined! Only call from render code!")
|
||||||
|
|
||||||
enum class UnsafeMode {
|
enum class UnsafeMode {
|
||||||
UNSAFE_ALLOWED,
|
UNSAFE_ALLOWED,
|
||||||
@@ -52,12 +52,12 @@ abstract class Komponent {
|
|||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
currentKomponent = this
|
currentKomponents.add(this)
|
||||||
builder.render()
|
builder.render()
|
||||||
} catch(e: KomponentException) {
|
} catch(e: KomponentException) {
|
||||||
errorHandler(e)
|
errorHandler(e)
|
||||||
} finally {
|
} finally {
|
||||||
currentKomponent = null
|
currentKomponents.removeLast()
|
||||||
}
|
}
|
||||||
|
|
||||||
element = builder.root
|
element = builder.root
|
||||||
@@ -148,12 +148,12 @@ abstract class Komponent {
|
|||||||
val builder = HtmlBuilder(this, parent, childIndex)
|
val builder = HtmlBuilder(this, parent, childIndex)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
currentKomponent = this
|
currentKomponents.add(this)
|
||||||
builder.render()
|
builder.render()
|
||||||
} catch(e: KomponentException) {
|
} catch(e: KomponentException) {
|
||||||
errorHandler(e)
|
errorHandler(e)
|
||||||
} finally {
|
} finally {
|
||||||
currentKomponent = null
|
currentKomponents.removeLast()
|
||||||
}
|
}
|
||||||
|
|
||||||
element = builder.root
|
element = builder.root
|
||||||
|
|||||||
Reference in New Issue
Block a user