JS: fix some code in stdlib that attempts to to is check against native interface
This commit is contained in:
@@ -40,9 +40,13 @@ public fun Node.on(name: String, capture: Boolean, handler: (Event) -> Unit): Cl
|
|||||||
* Registers an [EventListener] on the named event
|
* Registers an [EventListener] on the named event
|
||||||
*/
|
*/
|
||||||
public fun Node?.on(name: String, capture: Boolean, listener: EventListener): Closeable? {
|
public fun Node?.on(name: String, capture: Boolean, listener: EventListener): Closeable? {
|
||||||
return if (this is EventTarget) {
|
// TODO: instanceof EventTarget is a very bad idea!
|
||||||
addEventListener(name, listener, capture)
|
// TODO: nullable target is a very bad idea!
|
||||||
CloseableEventListener(this, listener, name, capture)
|
// TODO: receiver should be EventTarget
|
||||||
|
val target = this as? EventTarget
|
||||||
|
return if (target != null) {
|
||||||
|
target.addEventListener(name, listener, capture)
|
||||||
|
CloseableEventListener(target, listener, name, capture)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user