MCPcopy Create free account
hub / github.com/breck7/scroll / walk

Function walk

external/.scrollLibs.js:12519–12559  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

12517 }
12518 }
12519 function walk(node) {
12520 if (node.nodeType == 1) {
12521 var cmText = node.getAttribute("cm-text")
12522 if (cmText) {
12523 addText(cmText)
12524 return
12525 }
12526 var markerID = node.getAttribute("cm-marker"),
12527 range$$1
12528 if (markerID) {
12529 var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID))
12530 if (found.length && (range$$1 = found[0].find(0))) {
12531 addText(getBetween(cm.doc, range$$1.from, range$$1.to).join(lineSep))
12532 }
12533 return
12534 }
12535 if (node.getAttribute("contenteditable") == "false") {
12536 return
12537 }
12538 var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName)
12539 if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) {
12540 return
12541 }
12542
12543 if (isBlock) {
12544 close()
12545 }
12546 for (var i = 0; i < node.childNodes.length; i++) {
12547 walk(node.childNodes[i])
12548 }
12549
12550 if (/^(pre|p)$/i.test(node.nodeName)) {
12551 extraLinebreak = true
12552 }
12553 if (isBlock) {
12554 closing = true
12555 }
12556 } else if (node.nodeType == 3) {
12557 addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " "))
12558 }
12559 }
12560 for (;;) {
12561 walk(from)
12562 if (from == to) {

Callers 1

domTextBetweenFunction · 0.85

Calls 9

addTextFunction · 0.85
PosFunction · 0.85
recognizeMarkerFunction · 0.85
getBetweenFunction · 0.85
getAttributeMethod · 0.80
replaceMethod · 0.80
closeFunction · 0.70
findMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected