@@ -777,13 +777,18 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
777777 // The assumption is that future DOM event attribute names will begin with
778778 // 'on' and be composed of only English letters.
779779 var EVENT_HANDLER_ATTR_REGEXP = / ^ ( o n [ a - z ] + | f o r m a c t i o n ) $ / ;
780+ var bindingCache = createMap ( ) ;
780781
781782 function parseIsolateBindings ( scope , directiveName , isController ) {
782783 var LOCAL_REGEXP = / ^ \s * ( [ @ & ] | = ( \* ? ) ) ( \? ? ) \s * ( \w * ) \s * $ / ;
783784
784785 var bindings = { } ;
785786
786787 forEach ( scope , function ( definition , scopeName ) {
788+ if ( definition in bindingCache ) {
789+ bindings [ scopeName ] = bindingCache [ definition ] ;
790+ return ;
791+ }
787792 var match = definition . match ( LOCAL_REGEXP ) ;
788793
789794 if ( ! match ) {
@@ -801,6 +806,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
801806 optional : match [ 3 ] === '?' ,
802807 attrName : match [ 4 ] || scopeName
803808 } ;
809+ if ( match [ 4 ] ) {
810+ bindingCache [ definition ] = bindings [ scopeName ] ;
811+ }
804812 } ) ;
805813
806814 return bindings ;
@@ -893,11 +901,6 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
893901 directive . name = directive . name || name ;
894902 directive . require = directive . require || ( directive . controller && directive . name ) ;
895903 directive . restrict = directive . restrict || 'EA' ;
896- var bindings = directive . $$bindings =
897- parseDirectiveBindings ( directive , directive . name ) ;
898- if ( isObject ( bindings . isolateScope ) ) {
899- directive . $$isolateBindings = bindings . isolateScope ;
900- }
901904 directive . $$moduleName = directiveFactory . $$moduleName ;
902905 directives . push ( directive ) ;
903906 } catch ( e ) {
@@ -2169,6 +2172,13 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
21692172 if ( startAttrName ) {
21702173 directive = inherit ( directive , { $$start : startAttrName , $$end : endAttrName } ) ;
21712174 }
2175+ if ( ! directive . $$bindings ) {
2176+ var bindings = directive . $$bindings =
2177+ parseDirectiveBindings ( directive , directive . name ) ;
2178+ if ( isObject ( bindings . isolateScope ) ) {
2179+ directive . $$isolateBindings = bindings . isolateScope ;
2180+ }
2181+ }
21722182 tDirectives . push ( directive ) ;
21732183 match = directive ;
21742184 }
0 commit comments