($provide, $$sanitizeUriProvider)
| 6822 | */ |
| 6823 | $CompileProvider.$inject = ['$provide', '$$sanitizeUriProvider']; |
| 6824 | function $CompileProvider($provide, $$sanitizeUriProvider) { |
| 6825 | var hasDirectives = {}, |
| 6826 | Suffix = 'Directive', |
| 6827 | COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\w\-]+)\s+(.*)$/, |
| 6828 | CLASS_DIRECTIVE_REGEXP = /(([\w\-]+)(?:\:([^;]+))?;?)/, |
| 6829 | ALL_OR_NOTHING_ATTRS = makeMap('ngSrc,ngSrcset,src,srcset'), |
| 6830 | REQUIRE_PREFIX_REGEXP = /^(?:(\^\^?)?(\?)?(\^\^?)?)?/; |
| 6831 | |
| 6832 | // Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes |
| 6833 | // The assumption is that future DOM event attribute names will begin with |
| 6834 | // 'on' and be composed of only English letters. |
| 6835 | var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/; |
| 6836 | |
| 6837 | function parseIsolateBindings(scope, directiveName, isController) { |
| 6838 | var LOCAL_REGEXP = /^\s*([@&]|=(\*?))(\??)\s*(\w*)\s*$/; |
| 6839 | |
| 6840 | var bindings = {}; |
| 6841 | |
| 6842 | forEach(scope, function(definition, scopeName) { |
| 6843 | var match = definition.match(LOCAL_REGEXP); |
| 6844 | |
| 6845 | if (!match) { |
| 6846 | throw $compileMinErr('iscp', |
| 6847 | "Invalid {3} for directive '{0}'." + |
| 6848 | " Definition: {... {1}: '{2}' ...}", |
| 6849 | directiveName, scopeName, definition, |
| 6850 | (isController ? "controller bindings definition" : |
| 6851 | "isolate scope definition")); |
| 6852 | } |
| 6853 | |
| 6854 | bindings[scopeName] = { |
| 6855 | mode: match[1][0], |
| 6856 | collection: match[2] === '*', |
| 6857 | optional: match[3] === '?', |
| 6858 | attrName: match[4] || scopeName |
| 6859 | }; |
| 6860 | }); |
| 6861 | |
| 6862 | return bindings; |
| 6863 | } |
| 6864 | |
| 6865 | function parseDirectiveBindings(directive, directiveName) { |
| 6866 | var bindings = { |
| 6867 | isolateScope: null, |
| 6868 | bindToController: null |
| 6869 | }; |
| 6870 | if (isObject(directive.scope)) { |
| 6871 | if (directive.bindToController === true) { |
| 6872 | bindings.bindToController = parseIsolateBindings(directive.scope, |
| 6873 | directiveName, true); |
| 6874 | bindings.isolateScope = {}; |
| 6875 | } else { |
| 6876 | bindings.isolateScope = parseIsolateBindings(directive.scope, |
| 6877 | directiveName, false); |
| 6878 | } |
| 6879 | } |
| 6880 | if (isObject(directive.bindToController)) { |
| 6881 | bindings.bindToController = |
nothing calls this directly
no test coverage detected