* Compile an element and return a nodeLinkFn. * * @param {Element} el * @param {Object} options * @return {Function|null}
(el, options)
| 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. |
no test coverage detected