Closed zoechi closed 8 years ago
The $
object itself is a JsObject
. Unfortunately the JsObject class doesn't support generics so there isn't much we can do here :(.
It seems it always can be cast to an Element
. Are there exceptions?
The return value of the []
operator is always an Element
yes, but I don't know of an automated way to deal with that (without wrapping the $
object or something).
Would anyone be interested in a PR that adds something (maybe $+
?) that wraps the cast to Element
?
Why can't you just change the return type from js.JsObject
to Element
when
on call-site Element x = $['someid'];
seems to work fine.?
This getter is for $
, which is a JsObject
and not an Element
. The []
operator of that object is what is returning the Element
.
Now I get it!
Sorry, too much debugging today :-/
$
would need to return an instance of a class that wraps JsObject
and implements []
so that calls are forwarded to the wrapped JsObject
and declare a return type Element
.
Do you think it's to expensive to create such an instance? I guess it would need only one per element instance?
Is this intentional? It breaks autocompletion.