mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
contentcollector: Factor out call to .toLowerCase()
This commit is contained in:
parent
dd7fb1babe
commit
99625950c8
1 changed files with 4 additions and 3 deletions
|
@ -43,7 +43,8 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
||||||
// .tagName works with DOM and cheerio 0.22.0, but:
|
// .tagName works with DOM and cheerio 0.22.0, but:
|
||||||
// * With DOM, .tagName is an uppercase string.
|
// * With DOM, .tagName is an uppercase string.
|
||||||
// * With cheerio 0.22.0, .tagName is a lowercase string.
|
// * With cheerio 0.22.0, .tagName is a lowercase string.
|
||||||
nodeTagName: (n) => n.tagName,
|
// For consistency, this function always returns a lowercase string.
|
||||||
|
nodeTagName: (n) => n.tagName && n.tagName.toLowerCase(),
|
||||||
// .nodeValue works with DOM and cheerio 0.22.0.
|
// .nodeValue works with DOM and cheerio 0.22.0.
|
||||||
nodeValue: (n) => n.nodeValue,
|
nodeValue: (n) => n.nodeValue,
|
||||||
// Returns the number of Node children (n.childNodes.length), not the number of Element children
|
// Returns the number of Node children (n.childNodes.length), not the number of Element children
|
||||||
|
@ -88,7 +89,7 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
||||||
_blockElems[element] = 1;
|
_blockElems[element] = 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
const isBlockElement = (n) => !!_blockElems[(dom.nodeTagName(n) || '').toLowerCase()];
|
const isBlockElement = (n) => !!_blockElems[dom.nodeTagName(n) || ''];
|
||||||
|
|
||||||
const textify = (str) => sanitizeUnicode(
|
const textify = (str) => sanitizeUnicode(
|
||||||
str.replace(/(\n | \n)/g, ' ')
|
str.replace(/(\n | \n)/g, ' ')
|
||||||
|
@ -406,7 +407,7 @@ const makeContentCollector = (collectStyles, abrowser, apool, className2Author)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const tname = (dom.nodeTagName(node) || '').toLowerCase();
|
const tname = dom.nodeTagName(node) || '';
|
||||||
|
|
||||||
if (tname === 'img') {
|
if (tname === 'img') {
|
||||||
hooks.callAll('collectContentImage', {
|
hooks.callAll('collectContentImage', {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue