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

Fix LiteAdaptor's search for elements by class. mathjax/MathJax#2278. #416

Merged
merged 1 commit into from
Jan 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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