JS fix tests failed due to api change
This commit is contained in:
committed by
Sergey Mashkov
parent
4bc91ba652
commit
33c1d5d2cf
@@ -1,84 +0,0 @@
|
||||
|
||||
package org.w3c.dom.events
|
||||
|
||||
import org.w3c.dom.*
|
||||
import org.w3c.dom.views.*
|
||||
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateJavaScriptStubs.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
// Contains stub APIs for the W3C DOM API so we can delegate to the platform DOM instead
|
||||
|
||||
deprecated("Use org.w3c.dom instead")
|
||||
native public trait DocumentEvent {
|
||||
public fun createEvent(arg1: String?): Event = noImpl
|
||||
}
|
||||
|
||||
deprecated("Use org.w3c.dom instead")
|
||||
native public trait Event {
|
||||
public val bubbles: Boolean
|
||||
public val cancelable: Boolean
|
||||
public val currentTarget: EventTarget
|
||||
public val eventPhase: Short
|
||||
public val target: EventTarget
|
||||
public val timeStamp: Long
|
||||
public val type: String
|
||||
public fun initEvent(arg1: String?, arg2: Boolean, arg3: Boolean): Unit = noImpl
|
||||
public fun preventDefault(): Unit = noImpl
|
||||
public fun stopPropagation(): Unit = noImpl
|
||||
|
||||
public companion object {
|
||||
public val AT_TARGET: Short = 2
|
||||
public val BUBBLING_PHASE: Short = 3
|
||||
public val CAPTURING_PHASE: Short = 1
|
||||
}
|
||||
}
|
||||
|
||||
deprecated("Use org.w3c.dom instead")
|
||||
native public trait EventTarget {
|
||||
public fun addEventListener(arg1: String?, arg2: EventListener, arg3: Boolean): Unit = noImpl
|
||||
public fun dispatchEvent(arg1: Event?): Boolean = noImpl
|
||||
public fun removeEventListener(arg1: String?, arg2: EventListener, arg3: Boolean): Unit = noImpl
|
||||
}
|
||||
|
||||
deprecated("Use org.w3c.dom instead")
|
||||
native public trait MouseEvent: UIEvent {
|
||||
public val altKey: Boolean
|
||||
public val button: Short
|
||||
public val clientX: Int
|
||||
public val clientY: Int
|
||||
public val ctrlKey: Boolean
|
||||
public val metaKey: Boolean
|
||||
public val relatedTarget: EventTarget
|
||||
public val screenX: Int
|
||||
public val screenY: Int
|
||||
public val shiftKey: Boolean
|
||||
public fun initMouseEvent(arg1: String?, arg2: Boolean, arg3: Boolean, arg4: AbstractView, arg5: Int, arg6: Int, arg7: Int, arg8: Int, arg9: Int, arg10: Boolean, arg11: Boolean, arg12: Boolean, arg13: Boolean, arg14: Short, arg15: EventTarget): Unit = noImpl
|
||||
}
|
||||
|
||||
deprecated("Use org.w3c.dom instead")
|
||||
native public trait MutationEvent: Event {
|
||||
public val attrChange: Short
|
||||
public val attrName: String
|
||||
public val newValue: String
|
||||
public val prevValue: String
|
||||
public val relatedNode: Node
|
||||
public fun initMutationEvent(arg1: String?, arg2: Boolean, arg3: Boolean, arg4: Node, arg5: String?, arg6: String?, arg7: String?, arg8: Short): Unit = noImpl
|
||||
|
||||
public companion object {
|
||||
public val ADDITION: Short = 2
|
||||
public val MODIFICATION: Short = 1
|
||||
public val REMOVAL: Short = 3
|
||||
}
|
||||
}
|
||||
|
||||
deprecated("Use org.w3c.dom instead")
|
||||
native public trait UIEvent: Event {
|
||||
public val detail: Int
|
||||
public val view: AbstractView
|
||||
public fun initUIEvent(arg1: String?, arg2: Boolean, arg3: Boolean, arg4: AbstractView, arg5: Int): Unit = noImpl
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.w3c.dom.events
|
||||
|
||||
import org.w3c.dom.*
|
||||
import org.w3c.dom.views.*
|
||||
|
||||
/*
|
||||
TODO we should maybe update GeneratedJavaScriptStubs.kt to auto-create this file
|
||||
too so that we can have the implementation code generated for JS
|
||||
|
||||
See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
*/
|
||||
|
||||
deprecated("Use org.w3c.dom instead")
|
||||
public trait EventListener {
|
||||
public fun handleEvent(arg1: Event): Unit
|
||||
}
|
||||
@@ -31,15 +31,28 @@ public val localStorage: Storage = noImpl
|
||||
native
|
||||
public val sessionStorage: Storage = noImpl
|
||||
|
||||
|
||||
private class HTMLCollectionListView(val collection: HTMLCollection) : AbstractList<HTMLElement>() {
|
||||
override fun size(): Int = collection.length.toInt()
|
||||
override fun size(): Int = collection.length
|
||||
|
||||
override fun get(index: Int): HTMLElement =
|
||||
if (index in 0..size() - 1) collection.item(index) as HTMLElement
|
||||
else throw IndexOutOfBoundsException("index $index is not in range [0 .. ${size() - 1})")
|
||||
when {
|
||||
index in 0..size() - 1 -> collection.item(index) as HTMLElement
|
||||
else -> throw IndexOutOfBoundsException("index $index is not in range [0 .. ${size() - 1})")
|
||||
}
|
||||
}
|
||||
|
||||
public fun HTMLCollection.asList(): List<HTMLElement> = HTMLCollectionListView(this)
|
||||
|
||||
public fun HTMLCollection?.toElementList() : List<Element> = this?.asList() ?: emptyList()
|
||||
public fun HTMLCollection?.toElementList(): List<Element> = this?.asList() ?: emptyList()
|
||||
|
||||
private class DOMTokenListView(val delegate: DOMTokenList) : AbstractList<String>() {
|
||||
override fun size(): Int = delegate.length
|
||||
|
||||
override fun get(index: Int) =
|
||||
when {
|
||||
index in 0..size() - 1 -> delegate.item(index)!!
|
||||
else -> throw IndexOutOfBoundsException("index $index is not in range [0 .. ${size() - 1})")
|
||||
}
|
||||
}
|
||||
|
||||
public fun DOMTokenList.asList(): List<String> = DOMTokenListView(this)
|
||||
@@ -9,5 +9,5 @@ fun box(): String {
|
||||
element.appendChild(textNode)
|
||||
if (textNode.nodeType != Node.TEXT_NODE) return "The type of the node is ${textNode.nodeType}, ${Node.TEXT_NODE} was expected"
|
||||
if (element.nodeType != Node.ELEMENT_NODE) return "The type of the node is ${element.nodeType}, ${Node.ELEMENT_NODE} was expected"
|
||||
return element.textContent
|
||||
return element.textContent!!
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package kotlin.dom
|
||||
|
||||
import java.io.Closeable
|
||||
import org.w3c.dom.Node
|
||||
import org.w3c.dom.*
|
||||
import org.w3c.dom.events.*
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package test.js
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.browser.*
|
||||
import kotlin.dom.*
|
||||
import kotlin.test.*
|
||||
import org.w3c.dom.*
|
||||
|
||||
Reference in New Issue
Block a user