-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue where className attribute wasn't rendered correctly
- Loading branch information
Showing
6 changed files
with
100 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
example/style/src/main/scala/io/github/shogowada/scalajs/reactjs/example/style/Main.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.shogowada.scalajs.reactjs.example.style | ||
|
||
import io.github.shogowada.scalajs.reactjs.ReactDOM | ||
import io.github.shogowada.scalajs.reactjs.VirtualDOM._ | ||
import io.github.shogowada.scalajs.reactjs.elements.ReactElement | ||
import org.scalajs.dom | ||
|
||
import scala.scalajs.js.JSApp | ||
|
||
object Main extends JSApp { | ||
override def main(): Unit = { | ||
val mountNode = dom.document.createElement("div") | ||
dom.document.body.appendChild(mountNode) | ||
ReactDOM.render(Main(), mountNode) | ||
} | ||
|
||
def apply(): ReactElement = <.div()( | ||
<.div(^.id := "green-text", ^.className := Seq("green"))("Green text!"), | ||
<.div(^.id := "blue-big-text", ^.className := Seq("blue", "big"))("Blue big text!"), | ||
<.div(^.id := "red-text", ^.style := Map("color" -> "red"))("Red text!") | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<html> | ||
<head> | ||
<style> | ||
.green { | ||
color: green; | ||
} | ||
.blue { | ||
color: blue; | ||
} | ||
.big { | ||
font-size: 32pt; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<script src="../scalajs-bundler/main/scalajs-reactjs-example-style-fastopt-bundle.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
example/test/src/it/scala/io/github/shogowada/scalajs/reactjs/example/style/StyleTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.github.shogowada.scalajs.reactjs.example.style | ||
|
||
import io.github.shogowada.scalajs.reactjs.example.TestTargetServers | ||
import org.scalatest.concurrent.Eventually | ||
import org.scalatest.selenium.Firefox | ||
import org.scalatest.{Matchers, path} | ||
|
||
class StyleTest extends path.FreeSpec | ||
with Matchers | ||
with Eventually | ||
with Firefox { | ||
|
||
val server = TestTargetServers.style | ||
|
||
"given I am on the page" - { | ||
go to server.host | ||
|
||
"then it should show green text" in { | ||
find(id("green-text")).flatMap(_.attribute("class")) should equal(Option("green")) | ||
} | ||
|
||
"then it should show blue big text" in { | ||
find(id("blue-big-text")).flatMap(_.attribute("class")) should equal(Option("blue big")) | ||
} | ||
|
||
"then it should show red text" in { | ||
find(id("red-text")).flatMap(_.attribute("style")) should equal(Option("color: red;")) | ||
} | ||
} | ||
|
||
close() | ||
} |