@@ -1237,16 +1237,16 @@ function $CompileProvider($provide) {
1237
1237
1238
1238
// combine directives from the original node and from the template:
1239
1239
// - take the array of directives for this element
1240
- // - split it into two parts, those that were already applied and those that weren't
1241
- // - collect directives from the template, add them to the second group and sort them
1242
- // - append the second group with new directives to the first group
1243
- directives = directives . concat (
1244
- collectDirectives (
1245
- compileNode ,
1246
- directives . splice ( i + 1 , directives . length - ( i + 1 ) ) ,
1247
- newTemplateAttrs
1248
- )
1249
- ) ;
1240
+ // - split it into two parts, those that already applied (processed) and those that weren't (unprocessed)
1241
+ // - collect directives from the template and sort them by priority
1242
+ // - combine directives as: processed + template + unprocessed
1243
+ var templateDirectives = collectDirectives ( compileNode , [ ] , newTemplateAttrs ) ;
1244
+ var unprocessedDirectives = directives . splice ( i + 1 , directives . length - ( i + 1 ) ) ;
1245
+
1246
+ if ( newIsolateScopeDirective ) {
1247
+ markDirectivesAsIsolate ( templateDirectives ) ;
1248
+ }
1249
+ directives = directives . concat ( templateDirectives ) . concat ( unprocessedDirectives ) ;
1250
1250
mergeTemplateAttributes ( templateAttrs , newTemplateAttrs ) ;
1251
1251
1252
1252
ii = directives . length ;
@@ -1303,13 +1303,13 @@ function $CompileProvider($provide) {
1303
1303
if ( pre ) {
1304
1304
if ( attrStart ) pre = groupElementsLinkFnWrapper ( pre , attrStart , attrEnd ) ;
1305
1305
pre . require = directive . require ;
1306
- if ( newIsolateScopeDirective === directive ) pre . isolateScope = true ;
1306
+ if ( newIsolateScopeDirective === directive || directive . $$isolateScope ) pre . isolateScope = true ;
1307
1307
preLinkFns . push ( pre ) ;
1308
1308
}
1309
1309
if ( post ) {
1310
1310
if ( attrStart ) post = groupElementsLinkFnWrapper ( post , attrStart , attrEnd ) ;
1311
1311
post . require = directive . require ;
1312
- if ( newIsolateScopeDirective === directive ) post . isolateScope = true ;
1312
+ if ( newIsolateScopeDirective === directive || directive . $$isolateScope ) post . isolateScope = true ;
1313
1313
postLinkFns . push ( post ) ;
1314
1314
}
1315
1315
}
@@ -1501,6 +1501,12 @@ function $CompileProvider($provide) {
1501
1501
}
1502
1502
}
1503
1503
1504
+ function markDirectivesAsIsolate ( directives ) {
1505
+ // mark all directives as needing isolate scope.
1506
+ for ( var j = 0 , jj = directives . length ; j < jj ; j ++ ) {
1507
+ directives [ j ] = inherit ( directives [ j ] , { $$isolateScope : true } ) ;
1508
+ }
1509
+ }
1504
1510
1505
1511
/**
1506
1512
* looks up the directive and decorates it with exception handling and proper parameters. We
@@ -1616,7 +1622,12 @@ function $CompileProvider($provide) {
1616
1622
1617
1623
tempTemplateAttrs = { $attr : { } } ;
1618
1624
replaceWith ( $rootElement , $compileNode , compileNode ) ;
1619
- collectDirectives ( compileNode , directives , tempTemplateAttrs ) ;
1625
+ var templateDirectives = collectDirectives ( compileNode , [ ] , tempTemplateAttrs ) ;
1626
+
1627
+ if ( isObject ( origAsyncDirective . scope ) ) {
1628
+ markDirectivesAsIsolate ( templateDirectives ) ;
1629
+ }
1630
+ directives = templateDirectives . concat ( directives ) ;
1620
1631
mergeTemplateAttributes ( tAttrs , tempTemplateAttrs ) ;
1621
1632
} else {
1622
1633
compileNode = beforeTemplateCompileNode ;
0 commit comments