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

Function checkTerminalDirectives

01.GettingStarted/js/vue.js:7374–7409  ·  view source on GitHub ↗

* Check an element for terminal directives in fixed order. * If it finds one, return a terminal link function. * * @param {Element} el * @param {Array} attrs * @param {Object} options * @return {Function} terminalLinkFn

(el, attrs, options)

Source from the content-addressed store, hash-verified

7372 */
7373
7374 function checkTerminalDirectives(el, attrs, options) {
7375 // skip v-pre
7376 if (getAttr(el, 'v-pre') !== null) {
7377 return skip;
7378 }
7379 // skip v-else block, but only if following v-if
7380 if (el.hasAttribute('v-else')) {
7381 var prev = el.previousElementSibling;
7382 if (prev && prev.hasAttribute('v-if')) {
7383 return skip;
7384 }
7385 }
7386
7387 var attr, name, value, modifiers, matched, dirName, rawName, arg, def, termDef;
7388 for (var i = 0, j = attrs.length; i < j; i++) {
7389 attr = attrs[i];
7390 name = attr.name.replace(modifierRE, '');
7391 if (matched = name.match(dirAttrRE)) {
7392 def = resolveAsset(options, 'directives', matched[1]);
7393 if (def && def.terminal) {
7394 if (!termDef || (def.priority || DEFAULT_TERMINAL_PRIORITY) > termDef.priority) {
7395 termDef = def;
7396 rawName = attr.name;
7397 modifiers = parseModifiers(attr.name);
7398 value = attr.value;
7399 dirName = matched[1];
7400 arg = matched[2];
7401 }
7402 }
7403 }
7404 }
7405
7406 if (termDef) {
7407 return makeTerminalNodeLinkFn(el, dirName, value, options, termDef, rawName, arg, modifiers);
7408 }
7409 }
7410
7411 function skip() {}
7412 skip.terminal = true;

Callers 1

compileElementFunction · 0.70

Calls 4

getAttrFunction · 0.70
resolveAssetFunction · 0.70
parseModifiersFunction · 0.70
makeTerminalNodeLinkFnFunction · 0.70

Tested by

no test coverage detected