MCPcopy Index your code
hub / github.com/keepfool/vue-tutorials / compileTextNode

Function compileTextNode

06.Router/basic/js/vue.js:7153–7183  ·  view source on GitHub ↗

* Compile a textNode and return a nodeLinkFn. * * @param {TextNode} node * @param {Object} options * @return {Function|null} textNodeLinkFn

(node, options)

Source from the content-addressed store, hash-verified

7151 */
7152
7153 function compileTextNode(node, options) {
7154 // skip marked text nodes
7155 if (node._skip) {
7156 return removeText;
7157 }
7158
7159 var tokens = parseText(node.wholeText);
7160 if (!tokens) {
7161 return null;
7162 }
7163
7164 // mark adjacent text nodes as skipped,
7165 // because we are using node.wholeText to compile
7166 // all adjacent text nodes together. This fixes
7167 // issues in IE where sometimes it splits up a single
7168 // text node into multiple ones.
7169 var next = node.nextSibling;
7170 while (next && next.nodeType === 3) {
7171 next._skip = true;
7172 next = next.nextSibling;
7173 }
7174
7175 var frag = document.createDocumentFragment();
7176 var el, token;
7177 for (var i = 0, l = tokens.length; i < l; i++) {
7178 token = tokens[i];
7179 el = token.tag ? processTextToken(token, options) : document.createTextNode(token.value);
7180 frag.appendChild(el);
7181 }
7182 return makeTextNodeLinkFn(tokens, frag, options);
7183 }
7184
7185 /**
7186 * Linker for an skipped text node.

Callers 1

compileNodeFunction · 0.70

Calls 3

parseTextFunction · 0.70
processTextTokenFunction · 0.70
makeTextNodeLinkFnFunction · 0.70

Tested by

no test coverage detected