mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
chore($compile): clean up compiler tests
This commit is contained in:
parent
bcc3a021eb
commit
2491319575
1 changed files with 123 additions and 122 deletions
|
|
@ -1,12 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
describe('$compile', function() {
|
||||
var element;
|
||||
var element, directive;
|
||||
|
||||
beforeEach(module(provideLog, function($provide, $compileProvider){
|
||||
element = null;
|
||||
directive = $compileProvider.directive;
|
||||
|
||||
$compileProvider.directive('log', function(log) {
|
||||
directive('log', function(log) {
|
||||
return {
|
||||
restrict: 'CAM',
|
||||
priority:0,
|
||||
|
|
@ -16,40 +17,40 @@ describe('$compile', function() {
|
|||
};
|
||||
});
|
||||
|
||||
$compileProvider.directive('highLog', function(log) {
|
||||
directive('highLog', function(log) {
|
||||
return { restrict: 'CAM', priority:3, compile: valueFn(function(scope, element, attrs) {
|
||||
log(attrs.highLog || 'HIGH');
|
||||
})};
|
||||
});
|
||||
|
||||
$compileProvider.directive('mediumLog', function(log) {
|
||||
directive('mediumLog', function(log) {
|
||||
return { restrict: 'CAM', priority:2, compile: valueFn(function(scope, element, attrs) {
|
||||
log(attrs.mediumLog || 'MEDIUM');
|
||||
})};
|
||||
});
|
||||
|
||||
$compileProvider.directive('greet', function() {
|
||||
directive('greet', function() {
|
||||
return { restrict: 'CAM', priority:10, compile: valueFn(function(scope, element, attrs) {
|
||||
element.text("Hello " + attrs.greet);
|
||||
})};
|
||||
});
|
||||
|
||||
$compileProvider.directive('set', function() {
|
||||
directive('set', function() {
|
||||
return function(scope, element, attrs) {
|
||||
element.text(attrs.set);
|
||||
};
|
||||
});
|
||||
|
||||
$compileProvider.directive('mediumStop', valueFn({
|
||||
directive('mediumStop', valueFn({
|
||||
priority: 2,
|
||||
terminal: true
|
||||
}));
|
||||
|
||||
$compileProvider.directive('stop', valueFn({
|
||||
directive('stop', valueFn({
|
||||
terminal: true
|
||||
}));
|
||||
|
||||
$compileProvider.directive('negativeStop', valueFn({
|
||||
directive('negativeStop', valueFn({
|
||||
priority: -100, // even with negative priority we still should be able to stop descend
|
||||
terminal: true
|
||||
}));
|
||||
|
|
@ -63,8 +64,8 @@ describe('$compile', function() {
|
|||
|
||||
describe('configuration', function() {
|
||||
it('should register a directive', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('div', function(log) {
|
||||
module(function() {
|
||||
directive('div', function(log) {
|
||||
return {
|
||||
restrict: 'ECA',
|
||||
link: function(scope, element) {
|
||||
|
|
@ -82,14 +83,14 @@ describe('$compile', function() {
|
|||
});
|
||||
|
||||
it('should allow registration of multiple directives with same name', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('div', function(log) {
|
||||
module(function() {
|
||||
directive('div', function(log) {
|
||||
return {
|
||||
restrict: 'ECA',
|
||||
link: log.fn('1')
|
||||
};
|
||||
});
|
||||
$compileProvider.directive('div', function(log) {
|
||||
directive('div', function(log) {
|
||||
return {
|
||||
restrict: 'ECA',
|
||||
link: log.fn('2')
|
||||
|
|
@ -158,8 +159,8 @@ describe('$compile', function() {
|
|||
|
||||
it('should receive scope, element, and attributes', function() {
|
||||
var injector;
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('log', function($injector, $rootScope) {
|
||||
module(function() {
|
||||
directive('log', function($injector, $rootScope) {
|
||||
injector = $injector;
|
||||
return {
|
||||
restrict: 'CA',
|
||||
|
|
@ -194,12 +195,12 @@ describe('$compile', function() {
|
|||
describe('error handling', function() {
|
||||
|
||||
it('should handle exceptions', function() {
|
||||
module(function($compileProvider, $exceptionHandlerProvider) {
|
||||
module(function($exceptionHandlerProvider) {
|
||||
$exceptionHandlerProvider.mode('log');
|
||||
$compileProvider.directive('factoryError', function() { throw 'FactoryError'; });
|
||||
$compileProvider.directive('templateError',
|
||||
directive('factoryError', function() { throw 'FactoryError'; });
|
||||
directive('templateError',
|
||||
valueFn({ compile: function() { throw 'TemplateError'; } }));
|
||||
$compileProvider.directive('linkingError',
|
||||
directive('linkingError',
|
||||
valueFn(function() { throw 'LinkingError'; }));
|
||||
});
|
||||
inject(function($rootScope, $compile, $exceptionHandler) {
|
||||
|
|
@ -243,8 +244,8 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should allow changing the template structure after the current node', function() {
|
||||
module(function($compileProvider){
|
||||
$compileProvider.directive('after', valueFn({
|
||||
module(function(){
|
||||
directive('after', valueFn({
|
||||
compile: function(element) {
|
||||
element.after('<span log>B</span>');
|
||||
}
|
||||
|
|
@ -260,8 +261,8 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should allow changing the template structure after the current node inside ngRepeat', function() {
|
||||
module(function($compileProvider){
|
||||
$compileProvider.directive('after', valueFn({
|
||||
module(function(){
|
||||
directive('after', valueFn({
|
||||
compile: function(element) {
|
||||
element.after('<span log>B</span>');
|
||||
}
|
||||
|
|
@ -313,9 +314,9 @@ describe('$compile', function() {
|
|||
describe('restrict', function() {
|
||||
|
||||
it('should allow restriction of attributes', function() {
|
||||
module(function($compileProvider, $provide) {
|
||||
module(function() {
|
||||
forEach({div:'E', attr:'A', clazz:'C', all:'EAC'}, function(restrict, name) {
|
||||
$compileProvider.directive(name, function(log) {
|
||||
directive(name, function(log) {
|
||||
return {
|
||||
restrict: restrict,
|
||||
compile: valueFn(function(scope, element, attr) {
|
||||
|
|
@ -360,8 +361,8 @@ describe('$compile', function() {
|
|||
describe('template', function() {
|
||||
|
||||
|
||||
beforeEach(module(function($compileProvider) {
|
||||
$compileProvider.directive('replace', valueFn({
|
||||
beforeEach(module(function() {
|
||||
directive('replace', valueFn({
|
||||
restrict: 'CAM',
|
||||
replace: true,
|
||||
template: '<div class="log" style="width: 10px" high-log>Replace!</div>',
|
||||
|
|
@ -370,7 +371,7 @@ describe('$compile', function() {
|
|||
expect(element).toBe(attr.$$element);
|
||||
}
|
||||
}));
|
||||
$compileProvider.directive('append', valueFn({
|
||||
directive('append', valueFn({
|
||||
restrict: 'CAM',
|
||||
template: '<div class="log" style="width: 10px" high-log>Append!</div>',
|
||||
compile: function(element, attr) {
|
||||
|
|
@ -489,20 +490,20 @@ describe('$compile', function() {
|
|||
}));
|
||||
|
||||
it("should fail if replacing and template doesn't have a single root element", function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('noRootElem', function() {
|
||||
module(function() {
|
||||
directive('noRootElem', function() {
|
||||
return {
|
||||
replace: true,
|
||||
template: 'dada'
|
||||
}
|
||||
});
|
||||
$compileProvider.directive('multiRootElem', function() {
|
||||
directive('multiRootElem', function() {
|
||||
return {
|
||||
replace: true,
|
||||
template: '<div></div><div></div>'
|
||||
}
|
||||
});
|
||||
$compileProvider.directive('singleRootWithWhiteSpace', function() {
|
||||
directive('singleRootWithWhiteSpace', function() {
|
||||
return {
|
||||
replace: true,
|
||||
template: ' <div></div> \n'
|
||||
|
|
@ -531,22 +532,22 @@ describe('$compile', function() {
|
|||
describe('templateUrl', function() {
|
||||
|
||||
beforeEach(module(
|
||||
function($compileProvider) {
|
||||
$compileProvider.directive('hello', valueFn({
|
||||
function() {
|
||||
directive('hello', valueFn({
|
||||
restrict: 'CAM', templateUrl: 'hello.html', transclude: true
|
||||
}));
|
||||
$compileProvider.directive('cau', valueFn({
|
||||
directive('cau', valueFn({
|
||||
restrict: 'CAM', templateUrl:'cau.html'
|
||||
}));
|
||||
|
||||
$compileProvider.directive('cError', valueFn({
|
||||
directive('cError', valueFn({
|
||||
restrict: 'CAM',
|
||||
templateUrl:'error.html',
|
||||
compile: function() {
|
||||
throw Error('cError');
|
||||
}
|
||||
}));
|
||||
$compileProvider.directive('lError', valueFn({
|
||||
directive('lError', valueFn({
|
||||
restrict: 'CAM',
|
||||
templateUrl: 'error.html',
|
||||
compile: function() {
|
||||
|
|
@ -555,18 +556,18 @@ describe('$compile', function() {
|
|||
}));
|
||||
|
||||
|
||||
$compileProvider.directive('iHello', valueFn({
|
||||
directive('iHello', valueFn({
|
||||
restrict: 'CAM',
|
||||
replace: true,
|
||||
templateUrl: 'hello.html'
|
||||
}));
|
||||
$compileProvider.directive('iCau', valueFn({
|
||||
directive('iCau', valueFn({
|
||||
restrict: 'CAM',
|
||||
replace: true,
|
||||
templateUrl:'cau.html'
|
||||
}));
|
||||
|
||||
$compileProvider.directive('iCError', valueFn({
|
||||
directive('iCError', valueFn({
|
||||
restrict: 'CAM',
|
||||
replace: true,
|
||||
templateUrl:'error.html',
|
||||
|
|
@ -574,7 +575,7 @@ describe('$compile', function() {
|
|||
throw Error('cError');
|
||||
}
|
||||
}));
|
||||
$compileProvider.directive('iLError', valueFn({
|
||||
directive('iLError', valueFn({
|
||||
restrict: 'CAM',
|
||||
replace: true,
|
||||
templateUrl: 'error.html',
|
||||
|
|
@ -810,12 +811,12 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should prevent multiple templates per element', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('sync', valueFn({
|
||||
module(function() {
|
||||
directive('sync', valueFn({
|
||||
restrict: 'C',
|
||||
template: '<span></span>'
|
||||
}));
|
||||
$compileProvider.directive('async', valueFn({
|
||||
directive('async', valueFn({
|
||||
restrict: 'C',
|
||||
templateUrl: 'template.html'
|
||||
}));
|
||||
|
|
@ -831,9 +832,9 @@ describe('$compile', function() {
|
|||
|
||||
describe('delay compile / linking functions until after template is resolved', function(){
|
||||
var template;
|
||||
beforeEach(module(function($compileProvider) {
|
||||
function directive (name, priority, options) {
|
||||
$compileProvider.directive(name, function(log) {
|
||||
beforeEach(module(function() {
|
||||
function logDirective (name, priority, options) {
|
||||
directive(name, function(log) {
|
||||
return (extend({
|
||||
priority: priority,
|
||||
compile: function() {
|
||||
|
|
@ -844,15 +845,15 @@ describe('$compile', function() {
|
|||
});
|
||||
}
|
||||
|
||||
directive('first', 10);
|
||||
directive('second', 5, { templateUrl: 'second.html' });
|
||||
directive('third', 3);
|
||||
directive('last', 0);
|
||||
logDirective('first', 10);
|
||||
logDirective('second', 5, { templateUrl: 'second.html' });
|
||||
logDirective('third', 3);
|
||||
logDirective('last', 0);
|
||||
|
||||
directive('iFirst', 10, {replace: true});
|
||||
directive('iSecond', 5, {replace: true, templateUrl: 'second.html' });
|
||||
directive('iThird', 3, {replace: true});
|
||||
directive('iLast', 0, {replace: true});
|
||||
logDirective('iFirst', 10, {replace: true});
|
||||
logDirective('iSecond', 5, {replace: true, templateUrl: 'second.html' });
|
||||
logDirective('iThird', 3, {replace: true});
|
||||
logDirective('iLast', 0, {replace: true});
|
||||
}));
|
||||
|
||||
it('should flush after link append', inject(
|
||||
|
|
@ -990,10 +991,10 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it("should fail if replacing and template doesn't have a single root element", function() {
|
||||
module(function($exceptionHandlerProvider, $compileProvider) {
|
||||
module(function($exceptionHandlerProvider) {
|
||||
$exceptionHandlerProvider.mode('log');
|
||||
|
||||
$compileProvider.directive('template', function() {
|
||||
directive('template', function() {
|
||||
return {
|
||||
replace: true,
|
||||
templateUrl: 'template.html'
|
||||
|
|
@ -1029,9 +1030,9 @@ describe('$compile', function() {
|
|||
describe('scope', function() {
|
||||
var iscope;
|
||||
|
||||
beforeEach(module(function($compileProvider) {
|
||||
beforeEach(module(function() {
|
||||
forEach(['', 'a', 'b'], function(name) {
|
||||
$compileProvider.directive('scope' + uppercase(name), function(log) {
|
||||
directive('scope' + uppercase(name), function(log) {
|
||||
return {
|
||||
scope: true,
|
||||
restrict: 'CA',
|
||||
|
|
@ -1043,7 +1044,7 @@ describe('$compile', function() {
|
|||
}
|
||||
};
|
||||
});
|
||||
$compileProvider.directive('iscope' + uppercase(name), function(log) {
|
||||
directive('iscope' + uppercase(name), function(log) {
|
||||
return {
|
||||
scope: {},
|
||||
restrict: 'CA',
|
||||
|
|
@ -1056,7 +1057,7 @@ describe('$compile', function() {
|
|||
}
|
||||
};
|
||||
});
|
||||
$compileProvider.directive('tscope' + uppercase(name), function(log) {
|
||||
directive('tscope' + uppercase(name), function(log) {
|
||||
return {
|
||||
scope: true,
|
||||
restrict: 'CA',
|
||||
|
|
@ -1069,7 +1070,7 @@ describe('$compile', function() {
|
|||
}
|
||||
};
|
||||
});
|
||||
$compileProvider.directive('trscope' + uppercase(name), function(log) {
|
||||
directive('trscope' + uppercase(name), function(log) {
|
||||
return {
|
||||
scope: true,
|
||||
replace: true,
|
||||
|
|
@ -1083,7 +1084,7 @@ describe('$compile', function() {
|
|||
}
|
||||
};
|
||||
});
|
||||
$compileProvider.directive('tiscope' + uppercase(name), function(log) {
|
||||
directive('tiscope' + uppercase(name), function(log) {
|
||||
return {
|
||||
scope: {},
|
||||
restrict: 'CA',
|
||||
|
|
@ -1098,7 +1099,7 @@ describe('$compile', function() {
|
|||
};
|
||||
});
|
||||
});
|
||||
$compileProvider.directive('log', function(log) {
|
||||
directive('log', function(log) {
|
||||
return {
|
||||
restrict: 'CA',
|
||||
link: function(scope) {
|
||||
|
|
@ -1250,8 +1251,8 @@ describe('$compile', function() {
|
|||
describe('interpolation', function() {
|
||||
var observeSpy, attrValueDuringLinking;
|
||||
|
||||
beforeEach(module(function($compileProvider) {
|
||||
$compileProvider.directive('observer', function() {
|
||||
beforeEach(module(function() {
|
||||
directive('observer', function() {
|
||||
return function(scope, elm, attr) {
|
||||
observeSpy = jasmine.createSpy('$observe attr');
|
||||
|
||||
|
|
@ -1312,9 +1313,9 @@ describe('$compile', function() {
|
|||
it('should delegate exceptions to $exceptionHandler', function() {
|
||||
observeSpy = jasmine.createSpy('$observe attr').andThrow('ERROR');
|
||||
|
||||
module(function($compileProvider, $exceptionHandlerProvider) {
|
||||
module(function($exceptionHandlerProvider) {
|
||||
$exceptionHandlerProvider.mode('log');
|
||||
$compileProvider.directive('error', function() {
|
||||
directive('error', function() {
|
||||
return function(scope, elm, attr) {
|
||||
attr.$observe('someAttr', observeSpy);
|
||||
attr.$observe('someAttr', observeSpy);
|
||||
|
|
@ -1352,10 +1353,10 @@ describe('$compile', function() {
|
|||
|
||||
describe('link phase', function() {
|
||||
|
||||
beforeEach(module(function($compileProvider) {
|
||||
beforeEach(module(function() {
|
||||
|
||||
forEach(['a', 'b', 'c'], function(name) {
|
||||
$compileProvider.directive(name, function(log) {
|
||||
directive(name, function(log) {
|
||||
return {
|
||||
restrict: 'ECA',
|
||||
compile: function() {
|
||||
|
|
@ -1395,8 +1396,8 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should support link function on directive object', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('abc', valueFn({
|
||||
module(function() {
|
||||
directive('abc', valueFn({
|
||||
link: function(scope, element, attrs) {
|
||||
element.text(attrs.abc);
|
||||
}
|
||||
|
|
@ -1413,8 +1414,8 @@ describe('$compile', function() {
|
|||
describe('attrs', function() {
|
||||
|
||||
it('should allow setting of attributes', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive({
|
||||
module(function() {
|
||||
directive({
|
||||
setter: valueFn(function(scope, element, attr) {
|
||||
attr.$set('name', 'abc');
|
||||
attr.$set('disabled', true);
|
||||
|
|
@ -1433,8 +1434,8 @@ describe('$compile', function() {
|
|||
|
||||
it('should read boolean attributes as boolean only on control elements', function() {
|
||||
var value;
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive({
|
||||
module(function() {
|
||||
directive({
|
||||
input: valueFn({
|
||||
restrict: 'ECA',
|
||||
link:function(scope, element, attr) {
|
||||
|
|
@ -1451,8 +1452,8 @@ describe('$compile', function() {
|
|||
|
||||
it('should read boolean attributes as text on non-controll elements', function() {
|
||||
var value;
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive({
|
||||
module(function() {
|
||||
directive({
|
||||
div: valueFn({
|
||||
restrict: 'ECA',
|
||||
link:function(scope, element, attr) {
|
||||
|
|
@ -1468,8 +1469,8 @@ describe('$compile', function() {
|
|||
});
|
||||
|
||||
it('should allow setting of attributes', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive({
|
||||
module(function() {
|
||||
directive({
|
||||
setter: valueFn(function(scope, element, attr) {
|
||||
attr.$set('name', 'abc');
|
||||
attr.$set('disabled', true);
|
||||
|
|
@ -1487,10 +1488,10 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should create new instance of attr for each template stamping', function() {
|
||||
module(function($compileProvider, $provide) {
|
||||
module(function($provide) {
|
||||
var state = { first: [], second: [] };
|
||||
$provide.value('state', state);
|
||||
$compileProvider.directive({
|
||||
directive({
|
||||
first: valueFn({
|
||||
priority: 1,
|
||||
compile: function(templateElement, templateAttr) {
|
||||
|
|
@ -1540,8 +1541,8 @@ describe('$compile', function() {
|
|||
it('should properly $observe inside ng-repeat', function() {
|
||||
var spies = [];
|
||||
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('observer', function() {
|
||||
module(function() {
|
||||
directive('observer', function() {
|
||||
return function(scope, elm, attr) {
|
||||
spies.push(jasmine.createSpy('observer ' + spies.length));
|
||||
attr.$observe('some', spies[spies.length - 1]);
|
||||
|
|
@ -1575,8 +1576,8 @@ describe('$compile', function() {
|
|||
describe('$set', function() {
|
||||
var attr;
|
||||
beforeEach(function(){
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('input', valueFn({
|
||||
module(function() {
|
||||
directive('input', valueFn({
|
||||
restrict: 'ECA',
|
||||
link: function(scope, element, attr) {
|
||||
scope.attr = attr;
|
||||
|
|
@ -1634,8 +1635,8 @@ describe('$compile', function() {
|
|||
|
||||
describe('locals', function() {
|
||||
it('should marshal to locals', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('widget', function(log) {
|
||||
module(function() {
|
||||
directive('widget', function(log) {
|
||||
return {
|
||||
scope: {
|
||||
attr: 'attribute',
|
||||
|
|
@ -1690,8 +1691,8 @@ describe('$compile', function() {
|
|||
|
||||
describe('controller', function() {
|
||||
it('should inject locals to controller', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('widget', function(log) {
|
||||
module(function() {
|
||||
directive('widget', function(log) {
|
||||
return {
|
||||
controller: function(attr, prop, assign, read, exp){
|
||||
log(attr);
|
||||
|
|
@ -1732,8 +1733,8 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should get required controller', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('main', function(log) {
|
||||
module(function() {
|
||||
directive('main', function(log) {
|
||||
return {
|
||||
priority: 2,
|
||||
controller: function() {
|
||||
|
|
@ -1744,7 +1745,7 @@ describe('$compile', function() {
|
|||
}
|
||||
};
|
||||
});
|
||||
$compileProvider.directive('dep', function(log) {
|
||||
directive('dep', function(log) {
|
||||
return {
|
||||
priority: 1,
|
||||
require: 'main',
|
||||
|
|
@ -1753,7 +1754,7 @@ describe('$compile', function() {
|
|||
}
|
||||
};
|
||||
});
|
||||
$compileProvider.directive('other', function(log) {
|
||||
directive('other', function(log) {
|
||||
return {
|
||||
link: function(scope, element, attrs, controller) {
|
||||
log(!!controller); // should be false
|
||||
|
|
@ -1769,15 +1770,15 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should require controller on parent element',function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('main', function(log) {
|
||||
module(function() {
|
||||
directive('main', function(log) {
|
||||
return {
|
||||
controller: function() {
|
||||
this.name = 'main';
|
||||
}
|
||||
};
|
||||
});
|
||||
$compileProvider.directive('dep', function(log) {
|
||||
directive('dep', function(log) {
|
||||
return {
|
||||
require: '^main',
|
||||
link: function(scope, element, attrs, controller) {
|
||||
|
|
@ -1794,8 +1795,8 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should have optional controller on current element', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('dep', function(log) {
|
||||
module(function() {
|
||||
directive('dep', function(log) {
|
||||
return {
|
||||
require: '?main',
|
||||
link: function(scope, element, attrs, controller) {
|
||||
|
|
@ -1812,14 +1813,14 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should support multiple controllers', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('c1', valueFn({
|
||||
module(function() {
|
||||
directive('c1', valueFn({
|
||||
controller: function() { this.name = 'c1'; }
|
||||
}));
|
||||
$compileProvider.directive('c2', valueFn({
|
||||
directive('c2', valueFn({
|
||||
controller: function() { this.name = 'c2'; }
|
||||
}));
|
||||
$compileProvider.directive('dep', function(log) {
|
||||
directive('dep', function(log) {
|
||||
return {
|
||||
require: ['^c1', '^c2'],
|
||||
link: function(scope, element, attrs, controller) {
|
||||
|
|
@ -1839,12 +1840,12 @@ describe('$compile', function() {
|
|||
var syncCtrlSpy = jasmine.createSpy('sync controller'),
|
||||
asyncCtrlSpy = jasmine.createSpy('async controller');
|
||||
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('myDirectiveSync', valueFn({
|
||||
module(function() {
|
||||
directive('myDirectiveSync', valueFn({
|
||||
template: '<div>Hello!</div>',
|
||||
controller: syncCtrlSpy
|
||||
}));
|
||||
$compileProvider.directive('myDirectiveAsync', valueFn({
|
||||
directive('myDirectiveAsync', valueFn({
|
||||
templateUrl: 'myDirectiveAsync.html',
|
||||
controller: asyncCtrlSpy,
|
||||
compile: function() {
|
||||
|
|
@ -1877,8 +1878,8 @@ describe('$compile', function() {
|
|||
|
||||
describe('transclude', function() {
|
||||
it('should compile get templateFn', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('trans', function(log) {
|
||||
module(function() {
|
||||
directive('trans', function(log) {
|
||||
return {
|
||||
transclude: 'element',
|
||||
priority: 2,
|
||||
|
|
@ -1906,8 +1907,8 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should support transclude directive', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('trans', function() {
|
||||
module(function() {
|
||||
directive('trans', function() {
|
||||
return {
|
||||
transclude: 'content',
|
||||
replace: true,
|
||||
|
|
@ -1928,16 +1929,16 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should transclude transcluded content', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('book', valueFn({
|
||||
module(function() {
|
||||
directive('book', valueFn({
|
||||
transclude: 'content',
|
||||
template: '<div>book-<div chapter>(<div ng-transclude></div>)</div></div>'
|
||||
}));
|
||||
$compileProvider.directive('chapter', valueFn({
|
||||
directive('chapter', valueFn({
|
||||
transclude: 'content',
|
||||
templateUrl: 'chapter.html'
|
||||
}));
|
||||
$compileProvider.directive('section', valueFn({
|
||||
directive('section', valueFn({
|
||||
transclude: 'content',
|
||||
template: '<div>section-!<div ng-transclude></div>!</div></div>'
|
||||
}));
|
||||
|
|
@ -1961,13 +1962,13 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should only allow one transclude per element', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('first', valueFn({
|
||||
module(function() {
|
||||
directive('first', valueFn({
|
||||
scope: {},
|
||||
restrict: 'CA',
|
||||
transclude: 'content'
|
||||
}));
|
||||
$compileProvider.directive('second', valueFn({
|
||||
directive('second', valueFn({
|
||||
restrict: 'CA',
|
||||
transclude: 'content'
|
||||
}));
|
||||
|
|
@ -1982,8 +1983,8 @@ describe('$compile', function() {
|
|||
|
||||
|
||||
it('should remove transclusion scope, when the DOM is destroyed', function() {
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('box', valueFn({
|
||||
module(function() {
|
||||
directive('box', valueFn({
|
||||
transclude: 'content',
|
||||
scope: { name: 'evaluate', show: 'accessor' },
|
||||
template: '<div><h1>Hello: {{name}}!</h1><div ng-transclude></div></div>',
|
||||
|
|
@ -2024,8 +2025,8 @@ describe('$compile', function() {
|
|||
|
||||
it('should support transcluded element on root content', function() {
|
||||
var comment;
|
||||
module(function($compileProvider) {
|
||||
$compileProvider.directive('transclude', valueFn({
|
||||
module(function() {
|
||||
directive('transclude', valueFn({
|
||||
transclude: 'element',
|
||||
compile: function(element, attr, linker) {
|
||||
return function(scope, element, attr) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue