Skip to content
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

Inherit from a JS object #1002

Open
cmorin28 opened this issue Jan 23, 2025 · 5 comments
Open

Inherit from a JS object #1002

cmorin28 opened this issue Jan 23, 2025 · 5 comments

Comments

@cmorin28
Copy link

cmorin28 commented Jan 23, 2025

Hello and thank you for your great work !

I'm trying to create a web component with Java. To do this, and according to the standard, I need to inherit from HTMLElement. However, as HTMLElement itself inherits from JSObject, the compiler thinks that it is a native JavaScript class (which is not the case in this usage).

What can be done in this case?

@konsoletyper
Copy link
Owner

It's not possible directly by inheriting from HTMLElement. But you could write a function in pure JS that takes functions and creates/registers a web component, then call this function from TeaVM.

@cmorin28
Copy link
Author

@konsoletyper I find this solution quite ugly and I'd like to contribute to this project to get a more ‘conventional’ solution.
What do you think would be the best solution to make this possible?

@konsoletyper
Copy link
Owner

I find this solution quite ugly

It's a working solution, so how it can be ugly?

and I'd like to contribute to this project to get a more ‘conventional’ solution

Please, don't. I have quite bad experience with PRs and even considering to disable them

@cmorin28
Copy link
Author

cmorin28 commented Jan 25, 2025

It's a working solution, so how it can be ugly?

Maybe that's not the right word, sorry 😅. Let's just say that I would have preferred something that would provide something more uniform. We can create a class in the same way that DivElement inherits from HTMLElement and this allows us to take advantage of Java in the browser in the same way that we use JavaScript. Beyond Web Component, I find this limitation a bit annoying.

Please, don't. I have quite bad experience with PRs and even considering to disable them

It was really to help while leaving you in complete control. That's why I was asking how you would have gone about following your recommendations 🙂.
It's because I think your project is really great and the official website seemed to encourage us to contribute, but I understand that it's also very time-consuming when we're not 100% on it.

@konsoletyper
Copy link
Owner

Let's just say that I would have preferred something that would provide something more uniform

Yes, in the perfect world it would be better. But currently the world is not perfect. To accept it and use a workaround would be 1000 easier for you and me.

Beyond Web Component, I find this limitation a bit annoying.

Can you please provide a real-world use-case? Not imaginary, not hypothetical, but real world? I'll may consider then.

Also, please note that TeaVM is not about replacing JS with Java. JS is good for its part. WebComponents were designed to be programmed on JS, so JS is good for this task. Why would anyone want to write WebComponent on Java?

It was really to help while leaving you in complete control

In theory. In practice, I spend more time and more resources and have significantly less fun reviewing someone's PR, mentoring someone, arguing with someone, than if I did everything by myself. And often the person is not even motivated enough to go through the review process, so all my efforts result in nothing.

Also, when someone comes with their own agenda, it's not they helping me, it's me helping them. I think it's fair enough to treat the word "A helps B" if B wants C and A assists B in achieving B's goal. When help in something wasn't asked, then it's not a help. So, when some person comes with their idea, which is not in my roadmap and even contributes PR, I should charge them, say at least 200 EUR, for reviewing it.

It's because I think your project is really great

From engineering part yes, other aspects (business, sales, community, documentation) no. So I'd appreciate any help in these areas, but everyone is just trying to send me a PR.

and the official website seemed to encourage us to contribute

Please, don't misunderstand it. I don't want someone to contribute because I believe this helps me to improve project faster, quite opposite. I'm ready to invest my time and attention in someone to eventually get another major contributor to this project, so that it won't depend solely on my. However, it was never the case that someone emerges, who is motivated enough to get mentored and who is ready to become a long-term co-maintainer for this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants