Commit b87e1395 authored by Robert Knight's avatar Robert Knight

Rewrite a comment

Try to explain the issue with `textContent` in a better way.
parent dd0af4d8
/**
* Return the combined length of text nodes contained in `node`.
*
* This is different than `node.textContent` if called on a comment or processing
* instruction directly.
*
* @param {Node} node
*/
function nodeTextLength(node) {
switch (node.nodeType) {
case Node.ELEMENT_NODE:
case Node.TEXT_NODE:
// nb. `textContent` excludes text in comments and processing instructions
// when called on a parent element, so we don't need to subtract that here.
return /** @type {string} */ (node.textContent).length;
default:
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment