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

Element.attachShadow on MathML element #69

Open
fred-wang opened this issue Sep 16, 2019 · 3 comments
Open

Element.attachShadow on MathML element #69

fred-wang opened this issue Sep 16, 2019 · 3 comments
Labels

Comments

@fred-wang
Copy link
Contributor

See https://dom.spec.whatwg.org/#dom-element-attachshadow

@rwlbuis has a one-line patch to allow MathML elements too and @bkardell was able to use it for https://bkardell.com/blog/MathForward.html

@bkardell
Copy link
Collaborator

I don't think getting shadows in core is likely to happen too - core should have that as the vision, it's important because a number of steps required to enable us to get there (IDL sorting out, the shape of discussions about things like links, etc) do belong in core. I would suggest this issue itself move to v2.

@fred-wang
Copy link
Contributor Author

from june 1: level 2

@Jamesernator
Copy link

Jamesernator commented May 23, 2021

It would still be rather useful especially when combined with Custom Math Elements to enable slottable templates.

e.g. one could create say a summation element:

const template = Template.mathML`
  <mrow>
    <munderover>
      <mo part="summationSymbol">Σ</mo>
      <mrow><slot name="lowerBound"></slot></mrow>
      <msub><slot name="upperBound"></slot></mrow>
    </munderover>
    <slot></slot>
  </mrow>
`;

class SummationElement extends MathElement {
  #shadowRoot = this.attachShadow({ mode: "closed "});
  
  constructor() {
    super();
    this.#shadowRoot.append(...template.content.cloneNode(true));
  }
}

customElements.define("sum-", SummationElement, { namespace: MATH_NAMESPACE });
<math>
  <sum->
    <mrow slot="lowerBound">
       <mi>x</mi>
       <mo>=</mo>
       <mn>0</mn>
    </mrow>
    <mn slot="upperBound">10</mn>
    <mrow>
      <mi>x</mi>
      <mo>-</mo>
      <mn>1</mn>
    </mrow>
  </sum->
</math>

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

No branches or pull requests

4 participants