-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal demo of assigning style properties via just passing js object #1636
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,11 @@ import org.w3c.dom.HTMLElement | |
* are extracted to a separate methods. | ||
* | ||
*/ | ||
|
||
private external object Object { | ||
fun entries(obj: Any): Array<Array<String>> | ||
} | ||
|
||
open class AttrsBuilder<TElement : Element> : EventsListenerBuilder() { | ||
internal val attributesMap = mutableMapOf<String, String>() | ||
internal val styleBuilder = StyleBuilderImpl() | ||
|
@@ -43,6 +48,14 @@ open class AttrsBuilder<TElement : Element> : EventsListenerBuilder() { | |
styleBuilder.apply(builder) | ||
} | ||
|
||
fun style(propertyHolder: Any) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe adding one of our There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UPD: not now, since this PR won't be merged for now (as discussed above) |
||
styleBuilder.apply { | ||
Object.entries(propertyHolder).forEach { (k, v) -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you want to try with |
||
property(k, v) | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* [classes] adds all values passed as params to the element's classList. | ||
* This method acts cumulatively, that is, each call adds values to the classList. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this dependency in web/core?
I thought it's going to be added by users in their projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your understanding is 100% correct - just like I said at the meeting it's a fake PR - nobody is going to merge this one - it was just to illustrate so that we check whether we need this (and this dependency was added for test)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, thanks! :)
i forgot that it's a fake PR