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

Function makeTextNodeLinkFn

06.Router/basic/js/vue.js:7240–7264  ·  view source on GitHub ↗

* Build a function that processes a textNode. * * @param {Array } tokens * @param {DocumentFragment} frag

(tokens, frag)

Source from the content-addressed store, hash-verified

7238 */
7239
7240 function makeTextNodeLinkFn(tokens, frag) {
7241 return function textNodeLinkFn(vm, el, host, scope) {
7242 var fragClone = frag.cloneNode(true);
7243 var childNodes = toArray(fragClone.childNodes);
7244 var token, value, node;
7245 for (var i = 0, l = tokens.length; i < l; i++) {
7246 token = tokens[i];
7247 value = token.value;
7248 if (token.tag) {
7249 node = childNodes[i];
7250 if (token.oneTime) {
7251 value = (scope || vm).$eval(value);
7252 if (token.html) {
7253 replace(node, parseTemplate(value, true));
7254 } else {
7255 node.data = _toString(value);
7256 }
7257 } else {
7258 vm._bindDir(token.descriptor, node, host, scope);
7259 }
7260 }
7261 }
7262 replace(el, fragClone);
7263 };
7264 }
7265
7266 /**
7267 * Compile a node list and return a childLinkFn.

Callers 1

compileTextNodeFunction · 0.70

Calls 4

toArrayFunction · 0.70
replaceFunction · 0.70
parseTemplateFunction · 0.70
_toStringFunction · 0.70

Tested by

no test coverage detected