MCPcopy Index your code
hub / github.com/OneNoteDev/WebClipper / deserializationFn

Function deserializationFn

src/scripts/highlighting/textHighlighter.js:915–951  ·  view source on GitHub ↗
(hlDescriptor)

Source from the content-addressed store, hash-verified

913 }
914
915 function deserializationFn(hlDescriptor) {
916 var hl = {
917 wrapper: hlDescriptor[0],
918 text: hlDescriptor[1],
919 path: hlDescriptor[2].split(':'),
920 offset: hlDescriptor[3],
921 length: hlDescriptor[4]
922 },
923 elIndex = hl.path.pop(),
924 node = self.el,
925 hlNode,
926 highlight,
927 idx;
928
929 while (!!(idx = hl.path.shift())) {
930 node = node.childNodes[idx];
931 }
932
933 if (node.childNodes[elIndex-1] && node.childNodes[elIndex-1].nodeType === NODE_TYPE.TEXT_NODE) {
934 elIndex -= 1;
935 }
936
937 node = node.childNodes[elIndex];
938 hlNode = node.splitText(hl.offset);
939 hlNode.splitText(hl.length);
940
941 if (hlNode.nextSibling && !hlNode.nextSibling.nodeValue) {
942 dom(hlNode.nextSibling).remove();
943 }
944
945 if (hlNode.previousSibling && !hlNode.previousSibling.nodeValue) {
946 dom(hlNode.previousSibling).remove();
947 }
948
949 highlight = dom(hlNode).wrap(dom().fromHTML(hl.wrapper)[0]);
950 highlights.push(highlight);
951 }
952
953 hlDescriptors.forEach(function (hlDescriptor) {
954 try {

Callers 1

textHighlighter.jsFile · 0.85

Calls 1

domFunction · 0.85

Tested by

no test coverage detected