@@ -851,13 +851,18 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
851
851
// The assumption is that future DOM event attribute names will begin with
852
852
// 'on' and be composed of only English letters.
853
853
var EVENT_HANDLER_ATTR_REGEXP = / ^ ( o n [ a - z ] + | f o r m a c t i o n ) $ / ;
854
+ var bindingCache = createMap ( ) ;
854
855
855
856
function parseIsolateBindings ( scope , directiveName , isController ) {
856
857
var LOCAL_REGEXP = / ^ \s * ( [ @ & < ] | = ( \* ? ) ) ( \? ? ) \s * ( \w * ) \s * $ / ;
857
858
858
859
var bindings = { } ;
859
860
860
861
forEach ( scope , function ( definition , scopeName ) {
862
+ if ( definition in bindingCache ) {
863
+ bindings [ scopeName ] = bindingCache [ definition ] ;
864
+ return ;
865
+ }
861
866
var match = definition . match ( LOCAL_REGEXP ) ;
862
867
863
868
if ( ! match ) {
@@ -875,6 +880,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
875
880
optional : match [ 3 ] === '?' ,
876
881
attrName : match [ 4 ] || scopeName
877
882
} ;
883
+ if ( match [ 4 ] ) {
884
+ bindingCache [ definition ] = bindings [ scopeName ] ;
885
+ }
878
886
} ) ;
879
887
880
888
return bindings ;
@@ -967,11 +975,6 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
967
975
directive . name = directive . name || name ;
968
976
directive . require = directive . require || ( directive . controller && directive . name ) ;
969
977
directive . restrict = directive . restrict || 'EA' ;
970
- var bindings = directive . $$bindings =
971
- parseDirectiveBindings ( directive , directive . name ) ;
972
- if ( isObject ( bindings . isolateScope ) ) {
973
- directive . $$isolateBindings = bindings . isolateScope ;
974
- }
975
978
directive . $$moduleName = directiveFactory . $$moduleName ;
976
979
directives . push ( directive ) ;
977
980
} catch ( e ) {
@@ -2545,6 +2548,13 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2545
2548
if ( startAttrName ) {
2546
2549
directive = inherit ( directive , { $$start : startAttrName , $$end : endAttrName } ) ;
2547
2550
}
2551
+ if ( ! directive . $$bindings ) {
2552
+ var bindings = directive . $$bindings =
2553
+ parseDirectiveBindings ( directive , directive . name ) ;
2554
+ if ( isObject ( bindings . isolateScope ) ) {
2555
+ directive . $$isolateBindings = bindings . isolateScope ;
2556
+ }
2557
+ }
2548
2558
tDirectives . push ( directive ) ;
2549
2559
match = directive ;
2550
2560
}
0 commit comments