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

Function compileElement

06.Router/basic/js/vue.js:7112–7143  ·  view source on GitHub ↗

* Compile an element and return a nodeLinkFn. * * @param {Element} el * @param {Object} options * @return {Function|null}

(el, options)

Source from the content-addressed store, hash-verified

7110 */
7111
7112 function compileElement(el, options) {
7113 // preprocess textareas.
7114 // textarea treats its text content as the initial value.
7115 // just bind it as an attr directive for value.
7116 if (el.tagName === 'TEXTAREA') {
7117 var tokens = parseText(el.value);
7118 if (tokens) {
7119 el.setAttribute(':value', tokensToExp(tokens));
7120 el.value = '';
7121 }
7122 }
7123 var linkFn;
7124 var hasAttrs = el.hasAttributes();
7125 var attrs = hasAttrs && toArray(el.attributes);
7126 // check terminal directives (for & if)
7127 if (hasAttrs) {
7128 linkFn = checkTerminalDirectives(el, attrs, options);
7129 }
7130 // check element directives
7131 if (!linkFn) {
7132 linkFn = checkElementDirectives(el, options);
7133 }
7134 // check component
7135 if (!linkFn) {
7136 linkFn = checkComponent(el, options);
7137 }
7138 // normal directives
7139 if (!linkFn && hasAttrs) {
7140 linkFn = compileDirectives(attrs, options);
7141 }
7142 return linkFn;
7143 }
7144
7145 /**
7146 * Compile a textNode and return a nodeLinkFn.

Callers 1

compileNodeFunction · 0.70

Calls 7

parseTextFunction · 0.70
tokensToExpFunction · 0.70
toArrayFunction · 0.70
checkTerminalDirectivesFunction · 0.70
checkElementDirectivesFunction · 0.70
checkComponentFunction · 0.70
compileDirectivesFunction · 0.70

Tested by

no test coverage detected