Skip to content

Commit

Permalink
Fix LiteAdaptor's elementsByClass() function, and getElements(). Reso…
Browse files Browse the repository at this point in the history
…lves issue mathjax/MathJax#2278.
  • Loading branch information
dpvc committed Dec 31, 2019
1 parent d49f63b commit 0109be6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ts/adaptors/liteAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ export class LiteAdaptor extends AbstractDOMAdaptor<LiteElement, LiteText, LiteD
while (n) {
if (n.kind !== '#text' && n.kind !== '#comment') {
n = n as LiteElement;
const classes = (n.attributes['class'] || '').split(/ /);
if (classes.find(name)) {
let tags = [] as LiteElement[];
const classes = (n.attributes['class'] || '').trim().split(/ +/);
if (classes.includes(name)) {
tags.push(n);
}
if (n.children.length) {
stack = n.children.concat(stack);
Expand All @@ -211,7 +211,7 @@ export class LiteAdaptor extends AbstractDOMAdaptor<LiteElement, LiteText, LiteD
*/
public getElements(nodes: (string | LiteElement | LiteElement[])[], document: LiteDocument) {
let containers = [] as LiteElement[];
const body = this.body(this.document);
const body = this.body(document);
for (const node of nodes) {
if (typeof(node) === 'string') {
if (node.charAt(0) === '#') {
Expand Down

0 comments on commit 0109be6

Please sign in to comment.