currently its 60k LOC(inline +noinline) (generated) , each tag defined like ..
@inline
def caption(
tabIndex: U[Int] = undefined,
is: U[String] = undefined,
classID: U[String] = undefined,
contentEditable: U[String] = undefined,
role: U[String] = undefined,
style: U[js.Any] = undefined,
hidden: U[Boolean] = undefined,
ref: U[(_ <: dom.html.Element) => _] = undefined,
key: U[String | Int] = undefined,
dir: U[String] = undefined,
id: U[String] = undefined,
.. many more
@exclude extraAttributes: U[js.Object] = undefined)(children: ReactNode*) : ReactElement = {
val props = FunctionMacro()
if(extraAttributes.isDefined && extraAttributes != null) addJsObjects(props,extraAttributes.get)
if (developmentMode) React.createElement("caption",props,children :_*)
else inlineReactElement("caption",props,children :_*)
}
In above code we used macro to create js.Object from method params which expands to bunch of updateDynamic calls and we have extrraAttributes for unknown props at compile time which will add extra execution time while combing objects ,i think with new @ScalaJSDefined trait changes came in scala.js 0.6.14 we can make it better!
New Proposal :
lets have a global trait with all dom attributes
@ScalaJSDefined
trait DOMProps extends js.Object {
var tabIndex: U[Int] = undefined,
var is: U[String] = undefined,
var classID: U[String] = undefined,
var contentEditable: U[String] = undefined,
var role: U[String] = undefined,
var style: U[js.Any] = undefined,
......
}
def caption(props:DOMProps)(children:ReactNode*) = React.createElement("caption",props,children:_*)
//call site
caption(new DOMProps { id = "hello" ; tabIndex = 2})(children)
Pros :
1)we can have type safe DOM tags under 500LOC instead of 30K LOC before
2)no need of macros
3)no extra run time cost
Cons :
1)we need some extra typing new DOM Props{ at call site , but i think its not a big deal
currently its 60k LOC(inline +noinline) (generated) , each tag defined like ..
In above code we used macro to create js.Object from method params which expands to bunch of updateDynamic calls and we have
extrraAttributesfor unknown props at compile time which will add extra execution time while combing objects ,i think with new@ScalaJSDefined traitchanges came in scala.js 0.6.14 we can make it better!New Proposal :
lets have a global trait with all dom attributes
Pros :
1)we can have type safe DOM tags under 500LOC instead of 30K LOC before
2)no need of macros
3)no extra run time cost
Cons :
1)we need some extra typing
new DOM Props{at call site , but i think its not a big deal