Skip to content

Support .ownerMathElement (or something akin to it) #241

Open
@rschristian

Description

@rschristian

Hopefully this is the correct place for such a request, let me know if not!

I'm looking to add support for rendering MathML elements w/ the correct namespace in Preact, but an issue I'm running up against is that it's quite challenging for us to figure out the namespace an element currently lives in. For a (rough & a bit silly) example:

<math>
    {condition ? <mi>1</mi> : <mo>2</mo>}
</math>

During the first rendering pass, we're able to keep track of the namespace as we delve into the children of <math>, however, when condition changes at some point in the future, we need to figure out the namespace before creating whichever element we're swapping to. This poses a bit of a challenge with the existing API.

With SVGs, we use .ownerSVGElement !== undefined which is pretty effective. Unfortunately, modern MathML doesn't seem to have an equivalent we could use, though it looks like MathML 2 supported this.

Is this by chance something worth supporting? Not quite sure yet how we can work around this as we have quite tight perf & size limitations.

Edit: We can use .namespaceURI to determine the existing namespace, but this is a bit less than ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions