mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
contentcollector: Fix Element attribute accesses
The `attribs` property is only available on cheerio's Element-like objects; DOM Element objects do not have an `attribs` property. Switch to `dom.nodeAttr()` to fix the logic for browsers.
This commit is contained in:
parent
99625950c8
commit
8763c3bb29
1 changed files with 4 additions and 4 deletions
|
@ -491,14 +491,14 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
||||||
cc.doAttrib(state, 'strikethrough');
|
cc.doAttrib(state, 'strikethrough');
|
||||||
}
|
}
|
||||||
if (tname === 'ul' || tname === 'ol') {
|
if (tname === 'ul' || tname === 'ol') {
|
||||||
let type = node.attribs ? node.attribs.class : null;
|
let type = dom.nodeAttr(node, 'class');
|
||||||
const rr = cls && /(?:^| )list-([a-z]+[0-9]+)\b/.exec(cls);
|
const rr = cls && /(?:^| )list-([a-z]+[0-9]+)\b/.exec(cls);
|
||||||
// lists do not need to have a type, so before we make a wrong guess
|
// lists do not need to have a type, so before we make a wrong guess
|
||||||
// check if we find a better hint within the node's children
|
// check if we find a better hint within the node's children
|
||||||
if (!rr && !type) {
|
if (!rr && !type) {
|
||||||
for (const i in node.children) {
|
for (const i in node.children) {
|
||||||
if (node.children[i] && node.children[i].name === 'ul') {
|
if (node.children[i] && node.children[i].name === 'ul') {
|
||||||
type = node.children[i].attribs.class;
|
type = dom.nodeAttr(node.children[i], 'class');
|
||||||
if (type) {
|
if (type) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -509,8 +509,8 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
||||||
type = rr[1];
|
type = rr[1];
|
||||||
} else {
|
} else {
|
||||||
if (tname === 'ul') {
|
if (tname === 'ul') {
|
||||||
if ((type && type.match('indent')) ||
|
const cls = dom.nodeAttr(node, 'class');
|
||||||
(node.attribs && node.attribs.class && node.attribs.class.match('indent'))) {
|
if ((type && type.match('indent')) || (cls && cls.match('indent'))) {
|
||||||
type = 'indent';
|
type = 'indent';
|
||||||
} else {
|
} else {
|
||||||
type = 'bullet';
|
type = 'bullet';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue