0.0.0-web-dev-14 is built against Kotlin 1.5.10
We've again introduced breaking changes to the DOM API.
Changes in DOM API
Packages renamed
For consistency we've renamed all packages in following fashion:
androidx.compose.web
→org.jetbrains.compose.web
androidx.compose.web.elements
→org.jetbrains.compose.web.dom
Yep, we've colored your projects red, we apologize for any inconvenience you can possibly experience.
Changes of this kind are definitely not something we are going to annoy you with in future.
Basically, it's need to be done once.
style
parameter is no more, use attrs
instead
This change can be quite annoying since IDE won't be able to suggest quickfixes of any kind.
Manually, though, the changes one need to introduce very straightforward:
0.0.0-web-dev-13 | 0.0.0-web-dev-14 |
---|---|
Div(attrs = {}, style = { padding(15.px) })
| Div(attrs = { style { padding(15.px) } })
|
...
| Div(attrs = { styleBuilder.padding(15.px) })
|
Simplification of signatures is the reason why we've decided to move in this direction.
Direct styling is important but still definitely not something we should prioritize as something that is used / called equally often
as anything like attribute assignment and adding events. Apart from this, with new syntax it's easier to share context between events, styles and attributes.
classes
builder has been removed
Previously, it was possible to add classes using a builder:
Div(attrs = {
classes { // This is not possible since 0.0.0-web-dev-14
+"class1"
+"class2"
if (addClass3) +"class3"
}
})
Since, starting from 0.0.0-web-dev-13 classes
calls behave cumulatively, such builder became actually redundant.
After discussing this issue with community, we've decided to retire this construction. Long live, classes builder!
Use classes(...)
function, it is enough for all your needs:
Div(attrs = {
classes("class1", "class2")
if (addClass3) classes("class3")
})
All DOM creation elements can omit content
We've made content nullable so that one won't need to create empty builders instead.
0.0.0-web-dev-13 | 0.0.0-web-dev-14 |
---|---|
Span() {}
| Span()
|
Other recent updates:
- https://github.com/JetBrains/compose-jb/tree/master/examples/web-with-react - a couple of examples where Compose and React work together