Skip to content

Commit 7b10920

Browse files
authored
Merge pull request #1180 from mathjax/rename-stylelist
Rename StyleList to StyleJson, etc.
2 parents f171f7b + 7bb43db commit 7b10920

36 files changed

Lines changed: 222 additions & 210 deletions
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { describe, test, expect } from '@jest/globals';
2-
import {CssStyles} from '#js/util/StyleList.js';
2+
import {StyleJsonSheet} from '#js/util/StyleJson.js';
33

4-
describe('CssStyles object', () => {
4+
describe('StyleJsonSheet object', () => {
55

66
test('CssStyle creation', () => {
7-
expect(new CssStyles().cssText).toBe('');
8-
expect(new CssStyles({'.mjx': {padding: '0px'}}).cssText).toBe('.mjx {\n padding: 0px;\n}');
9-
expect(new CssStyles({
7+
expect(new StyleJsonSheet().cssText).toBe('');
8+
expect(new StyleJsonSheet({'.mjx': {padding: '0px'}}).cssText).toBe('.mjx {\n padding: 0px;\n}');
9+
expect(new StyleJsonSheet({
1010
'.mjx': {
1111
padding: '0px',
1212
'font-size': '150%'
@@ -27,7 +27,7 @@ describe('CssStyles object', () => {
2727
});
2828

2929
test('Add/remove styles', () => {
30-
const styles = new CssStyles();
30+
const styles = new StyleJsonSheet();
3131
styles.addStyles({p: {'font-weight': 'bold'}, h1: {'font-size': '150%'}, 'h2': {}});
3232
expect(styles.cssText).toBe('p {\n font-weight: bold;\n}\n\nh1 {\n font-size: 150%;\n}\n\nh2 {\n\n}');
3333
styles.removeStyles('h1', 'h2');

ts/a11y/assistive-mml.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
import { MmlNode } from '../core/MmlTree/MmlNode.js';
3737
import { SerializedMmlVisitor } from '../core/MmlTree/SerializedMmlVisitor.js';
3838
import { OptionList, expandable } from '../util/Options.js';
39-
import { StyleList } from '../util/StyleList.js';
39+
import { StyleJson } from '../util/StyleJson.js';
4040

4141
/*==========================================================================*/
4242

@@ -209,7 +209,7 @@ export function AssistiveMmlMathDocumentMixin<
209209
/**
210210
* styles needed for the hidden MathML
211211
*/
212-
public static assistiveStyles: StyleList = {
212+
public static assistiveStyles: StyleJson = {
213213
'mjx-assistive-mml': {
214214
position: 'absolute !important',
215215
top: '0px',

ts/a11y/explorer/Region.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
import { MathDocument } from '../../core/MathDocument.js';
25-
import { CssStyles } from '../../util/StyleList.js';
25+
import { StyleJsonSheet } from '../../util/StyleJson.js';
2626
import * as Sre from '../sre.js';
2727
import { SsmlElement, buildSpeech } from '../speech/SpeechUtil.js';
2828

@@ -83,9 +83,9 @@ export abstract class AbstractRegion<T> implements Region<T> {
8383
/**
8484
* The CSS style that needs to be added for this type of region.
8585
*
86-
* @type {CssStyles}
86+
* @type {StyleJsonSheet}
8787
*/
88-
protected static style: CssStyles;
88+
protected static style: StyleJsonSheet;
8989

9090
/**
9191
* The outer div node.
@@ -319,7 +319,7 @@ export class ToolTip extends StringRegion {
319319
/**
320320
* @override
321321
*/
322-
protected static style: CssStyles = new CssStyles({
322+
protected static style: StyleJsonSheet = new StyleJsonSheet({
323323
['.' + ToolTip.className]: {
324324
width: 'auto',
325325
height: 'auto',
@@ -345,7 +345,7 @@ export class LiveRegion extends StringRegion {
345345
/**
346346
* @override
347347
*/
348-
protected static style: CssStyles = new CssStyles({
348+
protected static style: StyleJsonSheet = new StyleJsonSheet({
349349
['.' + LiveRegion.className]: {
350350
position: 'absolute',
351351
top: 0,
@@ -537,7 +537,7 @@ export class HoverRegion extends AbstractRegion<HTMLElement> {
537537
/**
538538
* @override
539539
*/
540-
protected static style: CssStyles = new CssStyles({
540+
protected static style: StyleJsonSheet = new StyleJsonSheet({
541541
['.' + HoverRegion.className]: {
542542
display: 'block',
543543
position: 'absolute',

ts/handlers/html/HTMLDocument.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { HTMLDomStrings } from './HTMLDomStrings.js';
3434
import { DOMAdaptor } from '../../core/DOMAdaptor.js';
3535
import { InputJax } from '../../core/InputJax.js';
3636
import { STATE, ProtoItem, Location } from '../../core/MathItem.js';
37-
import { StyleList } from '../../util/StyleList.js';
37+
import { StyleJson } from '../../util/StyleJson.js';
3838

3939
/*****************************************************************/
4040
/**
@@ -81,7 +81,7 @@ export class HTMLDocument<N, T, D> extends AbstractMathDocument<N, T, D> {
8181
/**
8282
* Extra styles to be included in the document's stylesheet (added by extensions)
8383
*/
84-
protected styles: StyleList[];
84+
protected styles: StyleJson[];
8585

8686
/**
8787
* The DomString parser for locating the text in DOM trees
@@ -115,7 +115,7 @@ export class HTMLDocument<N, T, D> extends AbstractMathDocument<N, T, D> {
115115
* @param {number} index The position within the N's string that needs to be found
116116
* @param {string} delim The delimiter for this position
117117
* @param {HTMLNodeArray} nodes The list of node lists representing the string array
118-
* @returns {Location} The Location object for the position of the delimiter in the document
118+
* @returns {Location} The Location object for the position of the delimiter in the document
119119
*/
120120
protected findPosition(
121121
N: number,
@@ -143,7 +143,7 @@ export class HTMLDocument<N, T, D> extends AbstractMathDocument<N, T, D> {
143143
* @param {ProtoItem} item The proto math item to turn into an actual MathItem
144144
* @param {InputJax} jax The input jax to use for the MathItem
145145
* @param {HTMLNodeArray} nodes The array of node lists that produced the string array
146-
* @returns {HTMLMathItem} The MathItem for the given proto item
146+
* @returns {HTMLMathItem} The MathItem for the given proto item
147147
*/
148148
protected mathItem(
149149
item: ProtoItem<N, T>,
@@ -208,7 +208,7 @@ export class HTMLDocument<N, T, D> extends AbstractMathDocument<N, T, D> {
208208
*
209209
* @param {InputJax<N,T,D>} jax The jax being used
210210
* @param {N[]} containers The containers to be searched in order
211-
* @returns {HTMLMathList<N,T,D>} The list of MathItems found
211+
* @returns {HTMLMathList<N,T,D>} The list of MathItems found
212212
*/
213213
protected findMathFromStrings(
214214
jax: InputJax<N, T, D>,
@@ -233,7 +233,7 @@ export class HTMLDocument<N, T, D> extends AbstractMathDocument<N, T, D> {
233233
*
234234
* @param {InputJax<N,T,D>} jax The jax being used
235235
* @param {N[]} containers The containers to be searched in order
236-
* @returns {HTMLMathList<N,T,D>} The list of MathItems found
236+
* @returns {HTMLMathList<N,T,D>} The list of MathItems found
237237
*/
238238
protected findMathFromDOM(
239239
jax: InputJax<N, T, D>,
@@ -345,16 +345,16 @@ export class HTMLDocument<N, T, D> extends AbstractMathDocument<N, T, D> {
345345
/**
346346
* Add styles to be included in the document's stylesheet
347347
*
348-
* @param {StyleList} styles The styles to include
348+
* @param {StyleJson} styles The styles to include
349349
*/
350-
public addStyles(styles: StyleList) {
350+
public addStyles(styles: StyleJson) {
351351
this.styles.push(styles);
352352
}
353353

354354
/**
355-
* @returns {StyleList[]} Get the array of document-specific styles
355+
* @returns {StyleJson[]} The array of document-specific styles
356356
*/
357-
public getStyles(): StyleList[] {
357+
public getStyles(): StyleJson[] {
358358
return this.styles;
359359
}
360360
}

ts/output/chtml.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import { CommonOutputJax } from './common.js';
2525
import { CommonWrapper as _CommonWrapper } from './common/Wrapper.js';
2626
import { StyleList } from '../util/Styles.js';
27-
import { StyleList as CssStyleList, CssStyles } from '../util/StyleList.js';
27+
import { StyleJson, StyleJsonSheet } from '../util/StyleJson.js';
2828
import { OptionList } from '../util/Options.js';
2929
import { MathDocument } from '../core/MathDocument.js';
3030
import { MathItem } from '../core/MathItem.js';
@@ -91,7 +91,7 @@ export class CHTML<N, T, D> extends CommonOutputJax<
9191
/**
9292
* The default styles for CommonHTML
9393
*/
94-
public static commonStyles: CssStyleList = {
94+
public static commonStyles: StyleJson = {
9595
...CommonOutputJax.commonStyles,
9696
'mjx-container[jax="CHTML"]': {
9797
'white-space': 'nowrap',
@@ -219,7 +219,7 @@ export class CHTML<N, T, D> extends CommonOutputJax<
219219
*/
220220
public styleSheet(html: MathDocument<N, T, D>) {
221221
if (this.chtmlStyles) {
222-
const styles = new CssStyles();
222+
const styles = new StyleJsonSheet();
223223
if (this.options.adaptiveCSS) {
224224
//
225225
// Update the style sheet rules
@@ -238,16 +238,16 @@ export class CHTML<N, T, D> extends CommonOutputJax<
238238
}
239239

240240
/**
241-
* @param {CssStyles} styles The styles to update with newly used character styles
241+
* @param {StyleJsonSheet} styles The styles to update with newly used character styles
242242
*/
243-
protected updateFontStyles(styles: CssStyles) {
243+
protected updateFontStyles(styles: StyleJsonSheet) {
244244
styles.addStyles(this.font.updateStyles({}));
245245
}
246246

247247
/**
248248
* @override
249249
*/
250-
protected addWrapperStyles(styles: CssStyles) {
250+
protected addWrapperStyles(styles: StyleJsonSheet) {
251251
if (!this.options.adaptiveCSS) {
252252
super.addWrapperStyles(styles);
253253
return;
@@ -265,7 +265,10 @@ export class CHTML<N, T, D> extends CommonOutputJax<
265265
/**
266266
* @override
267267
*/
268-
protected addClassStyles(wrapper: typeof _CommonWrapper, styles: CssStyles) {
268+
protected addClassStyles(
269+
wrapper: typeof _CommonWrapper,
270+
styles: StyleJsonSheet
271+
) {
269272
const CLASS = wrapper as typeof ChtmlWrapper;
270273
if (CLASS.autoStyle && CLASS.kind !== 'unknown') {
271274
styles.addStyles({
@@ -291,7 +294,7 @@ export class CHTML<N, T, D> extends CommonOutputJax<
291294
* Clear the cache of which items need their styles to be output
292295
*/
293296
public clearCache() {
294-
this.cssStyles.clear();
297+
this.styleJson.clear();
295298
this.font.clearCache();
296299
this.wrapperUsage.clear();
297300
this.chtmlStyles = null;

0 commit comments

Comments
 (0)