Skip to content

Commit cf63292

Browse files
committed
test($compile): make IE8 happy
Closes angular#7828
1 parent fd420c4 commit cf63292

2 files changed

Lines changed: 30 additions & 17 deletions

File tree

test/ng/compileSpec.js

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3789,10 +3789,18 @@ describe('$compile', function() {
37893789
});
37903790

37913791
inject(function($compile, $rootScope) {
3792+
var message = 'Illegal use of ngTransclude directive in the template! No parent ' +
3793+
'directive that requires a transclusion found. Element: <div class="bar" ' +
3794+
'ng-transclude="">';
3795+
if (msie <= 8) {
3796+
// MSIE ヽ(`Д´)ノ
3797+
message = 'Illegal use of ngTransclude directive in the template! No parent ' +
3798+
'directive that requires a transclusion found. Element: <div class=bar ' +
3799+
'ng-transclude>';
3800+
}
37923801
expect(function() {
37933802
$compile('<div trans-foo>content</div>')($rootScope);
3794-
}).toThrowMinErr('ngTransclude', 'orphan',
3795-
'Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found. Element: <div class="bar" ng-transclude="">');
3803+
}).toThrowMinErr('ngTransclude', 'orphan', message);
37963804
});
37973805
});
37983806

@@ -3824,12 +3832,17 @@ describe('$compile', function() {
38243832
// This ng-transclude is invalid. It should throw an error.
38253833
'<div class="bar" ng-transclude></div>' +
38263834
'</div>');
3827-
3835+
var message = 'Illegal use of ngTransclude directive in the template! No parent directive that '
3836+
+ 'requires a transclusion found. Element: <div class="bar" ng-transclude="">';
3837+
if (msie <= 8) {
3838+
// MSIE ヽ(`Д´)ノ
3839+
message = 'Illegal use of ngTransclude directive in the template! No parent directive that '
3840+
+ 'requires a transclusion found. Element: <div class=bar ng-transclude>';
3841+
}
38283842
expect(function() {
38293843
element = $compile('<div trans-foo>content</div>')($rootScope);
38303844
$rootScope.$apply();
3831-
}).toThrowMinErr('ngTransclude', 'orphan',
3832-
'Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found. Element: <div class="bar" ng-transclude="">');
3845+
}).toThrowMinErr('ngTransclude', 'orphan', message);
38333846
});
38343847
});
38353848

@@ -4134,25 +4147,25 @@ describe('$compile', function() {
41344147
}));
41354148

41364149
$compileProvider.directive('transAsync', valueFn({
4137-
restrict: 'E',
4150+
restrict: 'A',
41384151
templateUrl: 'transAsync',
41394152
transclude: true
41404153
}));
41414154

41424155
$compileProvider.directive('iso', valueFn({
4143-
restrict: 'E',
4156+
restrict: 'A',
41444157
transclude: true,
4145-
template: '<trans><span ng-transclude></span></trans>',
4158+
template: '<div trans><span ng-transclude></span></div>',
41464159
scope: {}
41474160
}));
41484161
$compileProvider.directive('isoAsync1', valueFn({
4149-
restrict: 'E',
4162+
restrict: 'A',
41504163
transclude: true,
4151-
template: '<trans-async><span ng-transclude></span></trans-async>',
4164+
template: '<div trans-async><span ng-transclude></span></div>',
41524165
scope: {}
41534166
}));
41544167
$compileProvider.directive('isoAsync2', valueFn({
4155-
restrict: 'E',
4168+
restrict: 'A',
41564169
transclude: true,
41574170
templateUrl: 'isoAsync',
41584171
scope: {}
@@ -4161,30 +4174,30 @@ describe('$compile', function() {
41614174

41624175
beforeEach(inject(function($templateCache) {
41634176
$templateCache.put('transAsync', '<div ng-transclude></div>');
4164-
$templateCache.put('isoAsync', '<trans-async><span ng-transclude></span></trans-async>');
4177+
$templateCache.put('isoAsync', '<div trans-async><span ng-transclude></span></div>');
41654178
}));
41664179

41674180

41684181
it('should pass the outer scope to the transclude on the isolated template sync-sync', inject(function($compile, $rootScope) {
41694182

41704183
$rootScope.val = 'transcluded content';
4171-
element = $compile('<iso><span ng-bind="val"></span></iso>')($rootScope);
4184+
element = $compile('<div iso><span ng-bind="val"></span></div>')($rootScope);
41724185
$rootScope.$digest();
41734186
expect(element.text()).toEqual('transcluded content');
41744187
}));
41754188

41764189
it('should pass the outer scope to the transclude on the isolated template async-sync', inject(function($compile, $rootScope) {
41774190

41784191
$rootScope.val = 'transcluded content';
4179-
element = $compile('<iso-async1><span ng-bind="val"></span></iso-async1>')($rootScope);
4192+
element = $compile('<div iso-async1><span ng-bind="val"></span></div>')($rootScope);
41804193
$rootScope.$digest();
41814194
expect(element.text()).toEqual('transcluded content');
41824195
}));
41834196

41844197
it('should pass the outer scope to the transclude on the isolated template async-async', inject(function($compile, $rootScope) {
41854198

41864199
$rootScope.val = 'transcluded content';
4187-
element = $compile('<iso-async2><span ng-bind="val"></span></iso-async2>')($rootScope);
4200+
element = $compile('<div iso-async2><span ng-bind="val"></span></div>')($rootScope);
41884201
$rootScope.$digest();
41894202
expect(element.text()).toEqual('transcluded content');
41904203
}));

test/ng/directive/ngIfSpec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@ describe('ngIf and transcludes', function() {
207207
link: function(scope) {
208208
scope.val = 'value in iso scope';
209209
},
210-
restrict: 'E',
210+
restrict: 'A',
211211
transclude: true,
212212
template: '<div ng-if="true">val={{val}}-<div ng-transclude></div></div>',
213213
scope: {}
214214
}));
215215
});
216216
inject(function($compile, $rootScope) {
217217
$rootScope.val = 'transcluded content';
218-
var element = $compile('<iso><span ng-bind="val"></span></iso>')($rootScope);
218+
var element = $compile('<div iso><span ng-bind="val"></span></div>')($rootScope);
219219
$rootScope.$digest();
220220
expect(trim(element.text())).toEqual('val=value in iso scope-transcluded content');
221221
dealoc(element);

0 commit comments

Comments
 (0)