scala-js-dom icon indicating copy to clipboard operation
scala-js-dom copied to clipboard

Proposal for MathML base class

Open Quafadas opened this issue 1 year ago • 7 comments

  • run sbt prePR [x]
  • commit changes to api-reports [x]

This proposes a base class for MathML elements.

If it gets merged / agreed, I'd propose to follow it up with concrete elements following the style of the SVG elements, and the documentation here;

https://developer.mozilla.org/en-US/docs/Web/MathML

Related;

  • https://github.com/raquo/scala-dom-types/pulls
  • https://github.com/raquo/Laminar/issues/172

cc @raquo

Quafadas avatar Sep 22 '24 17:09 Quafadas

I've updated the two direct pieces of feedback - thankyou 🙏

Quafadas avatar Sep 25 '24 14:09 Quafadas

Just checking in - anything else I could do to nudge this forward?

Quafadas avatar Oct 01 '24 12:10 Quafadas

but in scalajs-dom interfaces, it's only defined for HTML elements. Unless there's a known reason for that, I think it should be defined for SVG (and now MathML) elements as well.

I do not know why it has been done like that, I'm not against this change however.

As for this PR, thank you! TIL about the MathML spec. I am wondering how faithful this implementation is to the MathML spec: https://w3c.github.io/mathml-core/#the-top-level-math-element, shouldn't this at least have the global attributes in the class: https://w3c.github.io/mathml-core/#global-attributes ?

zetashift avatar Oct 01 '24 17:10 zetashift

I am wondering how faithful this implementation is to the MathML spec: https://w3c.github.io/mathml-core/#the-top-level-math-element, shouldn't this at least have the global attributes in the class: https://w3c.github.io/mathml-core/#global-attributes ?

I think you are absolutely right. I'll try to add it. I think I got the on* properties through sheer luck parroting the SVG element. Thanks for the pointer, BRB...

Quafadas avatar Oct 01 '24 18:10 Quafadas

@zetashift done I believe. Thanks for the pointer 🙏

Quafadas avatar Oct 01 '24 18:10 Quafadas

Just checking in? Anything else I can do?

Quafadas avatar Oct 24 '24 11:10 Quafadas

Sorry! This looks good to me!

zetashift avatar Oct 24 '24 18:10 zetashift

@raquo I assume, that I also need to add the concrete mathML instances, before we can take advantage of it downstream? I'm planning to do that in a separate PR to keep this one small...

Quafadas avatar Oct 26 '24 10:10 Quafadas

@Quafadas Well, there are levels to this.

If we just have a single MathMLElement class that is shared by all MathML elements in the DOM, then in Laminar we can still type all MathML elements as instances of that one class, ignoring the subclasses. It will work, but you wouldn't be able to read any subclass-specific properties on such instances using el.ref.<propName>. You would still be able to set those properties via Laminar's usual syntax though, if you define those properties in Scala DOM Types.

FTR, I don't actually know how many of such subclass-specific properties MathML elements have.

raquo avatar Oct 26 '24 10:10 raquo

@raquo Thanks for the note.

I think what I'm proposing is that once this gets merged, I'll follow it straight up with another PR that puts up a complete list of the concrete elements.

Based on what you've said II think my proposal would be to be quite diligent on the top level math element, but I would prefer to avoid a big bike shedding exercise on the correctness of the sub-elements (that are rather niche). If they turned out to have meaningful properties, it should be easier to add them at a later date...

Does that sounds sensible?

Quafadas avatar Oct 26 '24 17:10 Quafadas

@Quafadas Thanks, sounds good to me, just keep in mind that you want to look at the MathMLElement superclass that is common to all MathML elements. The outer <math> element will likely have its own subclass of MathMLElement (not sure the exact name), so it may have properties on it that are not available on other types of MathML elements.

From what I see on MDN, it seems that the root <math> element only has display as the additional attribute. I assume it also reflects as a property, so should be present in the subclass definition, but I'm not sure.

raquo avatar Oct 27 '24 08:10 raquo

@zetashift Is there a remaining barrier to merging?

Quafadas avatar Oct 27 '24 08:10 Quafadas

Thank you!

zetashift avatar Oct 28 '24 19:10 zetashift

@zetashift Mostly thank you in fact :-)!

Quafadas avatar Oct 28 '24 19:10 Quafadas