konsoletyper / teavm

Compiles Java bytecode to JavaScript, WebAssembly and C
https://teavm.org
Apache License 2.0
2.55k stars 260 forks source link

Element fix #917

Closed Ihromant closed 1 month ago

Ihromant commented 1 month ago

https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML InnerHTML and other properties are a properties of Element, but not HTMLElement. This API mismatch caused inproper usage of JSO api which caused working incorrect code https://github.com/konsoletyper/teavm/issues/916 Incorrect code is fixed now, so properties should be moved to correct place.

Ihromant commented 1 month ago

Why closed this PR? It isn't incorrect and puts properties to the correct place and is backward compatible.

konsoletyper commented 1 month ago

This PR is incorrect.

Ihromant commented 1 month ago

It actually fixes issues I presented in https://github.com/konsoletyper/teavm/issues/916 when I create ElementNS, I can assign class to its classlist or setInnerHTML in JS. Due to this methods presence in JSO HTMLElement, this methods are inaccessible at all. What are you suggesting then?

konsoletyper commented 1 month ago

I don't understand the problem. Can you please clarify?

Ihromant commented 1 month ago
Element svg = HTMLDocument.current().createElementNS("svgschema", "svg);
// i want to set inner HTML or classList but I can't because it's not present in Element interface

Earlier it worked due to wrong typechecking on JS side like:

HTMLElement svg = HTMLDocument.current().createElementNS("svgschema", "svg).cast();
// use anything you need

Due to this fact, I didn't check that it's not in Element and used it against HTMLElement. Now it is broken because you fixed JS type system. So now we need to put properties in correct place. Please check MDN link I provided.

konsoletyper commented 1 month ago

First of all, MDN is non-normative and you can't refer on it. Second, there are two Element interfaces: from DOM spec and from HTML spec, and the one from DOM spec does not contain innerHTML property, and especially properties like clientWidth, since in general case a DOM application does not provide any visual representation.

Now, I just wasted 10 minutes of my time to explain you that instead of just improving TeaVM. When I said "this PR is incorrect" this means this PR is incorrect and you should accept it and try to figure out why youself.