@this
($provide, $$sanitizeUriProvider)
| 8115 | $CompileProvider.$inject = ['$provide', '$$sanitizeUriProvider']; |
| 8116 | /** @this */ |
| 8117 | function $CompileProvider($provide, $$sanitizeUriProvider) { |
| 8118 | var hasDirectives = {}, |
| 8119 | Suffix = 'Directive', |
| 8120 | COMMENT_DIRECTIVE_REGEXP = /^\s*directive:\s*([\w-]+)\s+(.*)$/, |
| 8121 | CLASS_DIRECTIVE_REGEXP = /(([\w-]+)(?::([^;]+))?;?)/, |
| 8122 | ALL_OR_NOTHING_ATTRS = makeMap('ngSrc,ngSrcset,src,srcset'), |
| 8123 | REQUIRE_PREFIX_REGEXP = /^(?:(\^\^?)?(\?)?(\^\^?)?)?/; |
| 8124 | |
| 8125 | // Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes |
| 8126 | // The assumption is that future DOM event attribute names will begin with |
| 8127 | // 'on' and be composed of only English letters. |
| 8128 | var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/; |
| 8129 | var bindingCache = createMap(); |
| 8130 | |
| 8131 | function parseIsolateBindings(scope, directiveName, isController) { |
| 8132 | var LOCAL_REGEXP = /^\s*([@&<]|=(\*?))(\??)\s*([\w$]*)\s*$/; |
| 8133 | |
| 8134 | var bindings = createMap(); |
| 8135 | |
| 8136 | forEach(scope, function(definition, scopeName) { |
| 8137 | if (definition in bindingCache) { |
| 8138 | bindings[scopeName] = bindingCache[definition]; |
| 8139 | return; |
| 8140 | } |
| 8141 | var match = definition.match(LOCAL_REGEXP); |
| 8142 | |
| 8143 | if (!match) { |
| 8144 | throw $compileMinErr('iscp', |
| 8145 | 'Invalid {3} for directive \'{0}\'.' + |
| 8146 | ' Definition: {... {1}: \'{2}\' ...}', |
| 8147 | directiveName, scopeName, definition, |
| 8148 | (isController ? 'controller bindings definition' : |
| 8149 | 'isolate scope definition')); |
| 8150 | } |
| 8151 | |
| 8152 | bindings[scopeName] = { |
| 8153 | mode: match[1][0], |
| 8154 | collection: match[2] === '*', |
| 8155 | optional: match[3] === '?', |
| 8156 | attrName: match[4] || scopeName |
| 8157 | }; |
| 8158 | if (match[4]) { |
| 8159 | bindingCache[definition] = bindings[scopeName]; |
| 8160 | } |
| 8161 | }); |
| 8162 | |
| 8163 | return bindings; |
| 8164 | } |
| 8165 | |
| 8166 | function parseDirectiveBindings(directive, directiveName) { |
| 8167 | var bindings = { |
| 8168 | isolateScope: null, |
| 8169 | bindToController: null |
| 8170 | }; |
| 8171 | if (isObject(directive.scope)) { |
| 8172 | if (directive.bindToController === true) { |
| 8173 | bindings.bindToController = parseIsolateBindings(directive.scope, |
| 8174 | directiveName, true); |
nothing calls this directly
no test coverage detected