-
Notifications
You must be signed in to change notification settings - Fork 38
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
Is there a good way to extend dom elements? #162
Comments
(This might be better submitted as a discussion, either here, the jsinterop-annotations repo, or GWT/j2cl depending on what you are targeting. Also consider the matrix/gitter chat room for GWT, at https://matrix.to/#/#gwtproject_gwt:gitter.im.) Can you describe how you would achieve what you're aiming for in plain JS? That should help make it clearer how you would do it with jsinterop/elemental2. For example, if you're trying to make custom elements, you will use Methods annotated with |
For example, the domino-ui Badge component is implemented via wrapper SpanElement, like this:
I want to check if the implementation can be implemented by inheriting SpanElement from the Badge, like this: This way the Badge comes with some of the properties and methods of the span element, can be used directly, but the two possible issues are how the Badge object create, and how some Badge new methods be overwritten by subclasses. |
If you do this, i.e. If you want to take advantage of writing the code in Java (e.g. overriding methods as mentioned above), you're better off using wrappers like the Domino UI example you shared or the current GWT |
@zbynek Thanks for your reply, I tried your suggestion, Badge object can be successfully created, but the extend methods of Badge will not be called successfully, the extend methods subclass rewriting will also be a problem, maybe wrap way is more extensible, thanks again. |
I want to add some new UI components by extends dom elements, so as to preserve the basic operation of dom elements, if wrap the dom elements to implement it, I need add some bridging methods, which are not as natural to use as dom elements.
If I extends like this, how would the Composite object be created?
class Composite extends HTMLDivElement { ... }
If I extends like this, will some extended methods not be able to be overridden by subclasses?
`@JsType(isNative = true, name = "HTMLDivElement", namespace = JsPackage.GLOBAL)
class Composite extends HTMLDivElement
{
@JsOverlay
public Composite create()
{
return Js.cast(DomGlobal.document.createElement("div"));
}
}`
The text was updated successfully, but these errors were encountered: