Skip to content

Commit

Permalink
Rename math template tag to mathml
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfagnani committed May 11, 2024
1 parent 9aca70c commit c219b9a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/labs/ssr/src/test/integration/tests/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import '@lit-labs/ssr-client/lit-element-hydrate-support.js';

import {html, math, svg, noChange, nothing, Part} from 'lit';
import {html, mathml, svg, noChange, nothing, Part} from 'lit';
import {html as staticHtml, literal} from 'lit/static-html.js';
import {
directive,
Expand Down Expand Up @@ -323,7 +323,7 @@ export const tests: {[name: string]: SSRTest} = {

'ChildPart accepts TemplateResult with MATHML type': {
render(x: unknown) {
return html` <math>${math`<mi>${x}</mi>`}</math> `;
return html` <math>${mathml`<mi>${x}</mi>`}</math> `;
},
expectations: [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/labs/ssr/src/test/test-files/render-test-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/

import {html, math, svg, nothing} from 'lit';
import {html, mathml, svg, nothing} from 'lit';
import {repeat} from 'lit/directives/repeat.js';
import {classMap} from 'lit/directives/class-map.js';
import {ref, createRef} from 'lit/directives/ref.js';
Expand Down Expand Up @@ -59,7 +59,7 @@ export const svgTemplate = (x: number, y: number, r: number) => svg`<circle cx="
// prettier-ignore
export const templateWithSvgTemplate = (x: number, y: number, r: number) => html`<svg>${svgTemplate(x, y, r)}</svg>`;
// prettier-ignore
export const mathTemplate = (x: number) => math`<mn>${x}</mn>`;
export const mathTemplate = (x: number) => mathml`<mn>${x}</mn>`;
// prettier-ignore
export const templateWithMathTemplate = (x: number) => html`<math>${mathTemplate(x)}</math>`;

Expand Down
8 changes: 4 additions & 4 deletions packages/lit-html/src/lit-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,17 +620,17 @@ export const svg = tag(SVG_RESULT);
* to and update a container.
*
* ```ts
* const num = math`<mn>1</mn>`;
* const num = mathml`<mn>1</mn>`;
*
* const eq = html`
* <math>
* ${num}
* </math>`;
* ```
*
* The `math` *tag function* should only be used for MathML fragments, or
* The `mathml` *tag function* should only be used for MathML fragments, or
* elements that would be contained **inside** a `<math>` HTML element. A common
* error is placing a `<math>` *element* in a template tagged with the `math`
* error is placing a `<math>` *element* in a template tagged with the `mathml`
* tag function. The `<math>` element is an HTML element and should be used
* within a template tagged with the {@linkcode html} tag function.
*
Expand All @@ -639,7 +639,7 @@ export const svg = tag(SVG_RESULT);
* element's shadow root and thus not be properly contained within a `<math>`
* HTML element.
*/
export const math = tag(MATHML_RESULT);
export const mathml = tag(MATHML_RESULT);

/**
* A sentinel value that signals that a value was handled by a directive and
Expand Down
6 changes: 3 additions & 3 deletions packages/lit-html/src/test/directive-helpers_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
CompiledTemplateResult,
CompiledTemplate,
UncompiledTemplateResult,
math,
mathml,
} from 'lit-html';
import {assert} from '@esm-bundle/chai';
import {stripExpressionComments} from '@lit-labs/testing';
Expand Down Expand Up @@ -74,7 +74,7 @@ suite('directive-helpers', () => {
test('isTemplateResult', () => {
assert.isTrue(isTemplateResult(html``));
assert.isTrue(isTemplateResult(svg``));
assert.isTrue(isTemplateResult(math``));
assert.isTrue(isTemplateResult(mathml``));
if (isTestFileNotCompiled) {
assert.isTrue(isTemplateResult(html``, TemplateResultType.HTML));
} else {
Expand All @@ -83,7 +83,7 @@ suite('directive-helpers', () => {
assert.isFalse(isTemplateResult(html``, TemplateResultType.HTML));
}
assert.isTrue(isTemplateResult(svg``, TemplateResultType.SVG));
assert.isTrue(isTemplateResult(math``, TemplateResultType.MATHML));
assert.isTrue(isTemplateResult(mathml``, TemplateResultType.MATHML));

assert.isFalse(isTemplateResult(null));
assert.isFalse(isTemplateResult(undefined));
Expand Down
8 changes: 4 additions & 4 deletions packages/lit-html/src/test/lit-html_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ChildPart,
CompiledTemplateResult,
html,
math,
mathml,
noChange,
nothing,
render,
Expand Down Expand Up @@ -799,7 +799,7 @@ suite('lit-html', () => {
suite('MathML', () => {
test('renders MathML', () => {
const container = document.createElement('math');
const t = math`<mi>x</mi>`;
const t = mathml`<mi>x</mi>`;
render(t, container);
const mi = container.firstElementChild!;
assert.equal(mi.tagName, 'mi');
Expand All @@ -812,8 +812,8 @@ suite('lit-html', () => {
staticAssertExtends<TemplateResult, MathMLTemplateResult>();
});

test('`math` returns a `MathMLTemplateResult`', () => {
staticAssertExtends<MathMLTemplateResult, ReturnType<typeof math>>();
test('`mathml` returns a `MathMLTemplateResult`', () => {
staticAssertExtends<MathMLTemplateResult, ReturnType<typeof mathml>>();
});
});

Expand Down

0 comments on commit c219b9a

Please sign in to comment.