@@ -777,13 +777,18 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
777
777
// The assumption is that future DOM event attribute names will begin with
778
778
// 'on' and be composed of only English letters.
779
779
var EVENT_HANDLER_ATTR_REGEXP = / ^ ( o n [ a - z ] + | f o r m a c t i o n ) $ / ;
780
+ var bindingCache = createMap ( ) ;
780
781
781
782
function parseIsolateBindings ( scope , directiveName , isController ) {
782
783
var LOCAL_REGEXP = / ^ \s * ( [ @ & ] | = ( \* ? ) ) ( \? ? ) \s * ( \w * ) \s * $ / ;
783
784
784
785
var bindings = { } ;
785
786
786
787
forEach ( scope , function ( definition , scopeName ) {
788
+ if ( definition in bindingCache ) {
789
+ bindings [ scopeName ] = bindingCache [ definition ] ;
790
+ return ;
791
+ }
787
792
var match = definition . match ( LOCAL_REGEXP ) ;
788
793
789
794
if ( ! match ) {
@@ -801,6 +806,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
801
806
optional : match [ 3 ] === '?' ,
802
807
attrName : match [ 4 ] || scopeName
803
808
} ;
809
+ if ( match [ 4 ] ) {
810
+ bindingCache [ definition ] = bindings [ scopeName ] ;
811
+ }
804
812
} ) ;
805
813
806
814
return bindings ;
@@ -893,11 +901,6 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
893
901
directive . name = directive . name || name ;
894
902
directive . require = directive . require || ( directive . controller && directive . name ) ;
895
903
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
- }
901
904
directive . $$moduleName = directiveFactory . $$moduleName ;
902
905
directives . push ( directive ) ;
903
906
} catch ( e ) {
@@ -2169,6 +2172,13 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
2169
2172
if ( startAttrName ) {
2170
2173
directive = inherit ( directive , { $$start : startAttrName , $$end : endAttrName } ) ;
2171
2174
}
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
+ }
2172
2182
tDirectives . push ( directive ) ;
2173
2183
match = directive ;
2174
2184
}
0 commit comments