Skip to content
This repository was archived by the owner on Jul 13, 2021. It is now read-only.

Commit 56e996a

Browse files
bashorSergey Mashkov
authored andcommitted
cleanup
1 parent 2f3a344 commit 56e996a

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

frontend/src/org/jetbrains/react/Imports.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ external interface ReactUpdater {
66
fun enqueueCallback(dest: Any, callback: Any, method: String)
77
}
88

9-
external interface ReactSpec {
10-
@JsName("createElement")
9+
@JsModule("react")
10+
@JsNonModule
11+
external object React {
1112
fun createElement(type: Any, props: dynamic, vararg child: Any): ReactElement
1213
}

frontend/src/org/jetbrains/react/ReactBuilder.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package react
22

3-
import runtime.reflect.*
4-
import runtime.wrappers.*
3+
import runtime.reflect.createInstance
54

65

76
@DslMarker
@@ -18,7 +17,7 @@ open class ReactBuilder {
1817
get() = type
1918

2019
fun create() : ReactElement {
21-
return React.createRaw(realType, props, children)
20+
return ReactWrapper.createRaw(realType, props, children)
2221
}
2322
}
2423

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
package react
22

3-
import runtime.wrappers.*
3+
import runtime.wrappers.toPlainObjectStripNull
44

55
interface ReactElement
66

7-
object React {
8-
9-
private val raw: ReactSpec = require("react")
10-
7+
internal object ReactWrapper {
118
fun normalize(child: Any?) : List<Any> = when(child) {
129
null -> listOf()
1310
is Iterable<*> -> child.filterNotNull()
@@ -16,5 +13,5 @@ object React {
1613
}
1714

1815
fun createRaw(type: Any, props: dynamic, child: Any? = null): ReactElement =
19-
raw.createElement(type, toPlainObjectStripNull(props), *normalize(child).toTypedArray())
16+
React.createElement(type, toPlainObjectStripNull(props), *normalize(child).toTypedArray())
2017
}

frontend/src/org/jetbrains/react/dom/ReactDOMComponent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package react.dom
22

3+
import org.w3c.dom.Element
34
import react.*
4-
import org.w3c.dom.*
55

66
abstract class ReactDOMComponent<P : RProps, S : RState> : ReactComponent<P, S>() {
77
abstract fun ReactDOMBuilder.render()
88

99
open fun ReactBuilder.children() {
10-
children.addAll(React.normalize(props.children))
10+
children.addAll(ReactWrapper.normalize(props.children))
1111
}
1212

1313
val DOMNode: Element

0 commit comments

Comments
 (0)