mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-15 10:13:10 +00:00
feat(Scope): expose transcluded and isolate scope info for batarang
test($compile): add test for exposing transclude and isolate scope info to batarang
This commit is contained in:
parent
971d97e2ec
commit
d7620f68bb
3 changed files with 42 additions and 0 deletions
|
|
@ -420,6 +420,7 @@ function $CompileProvider($provide) {
|
||||||
(function(transcludeFn) {
|
(function(transcludeFn) {
|
||||||
return function(cloneFn) {
|
return function(cloneFn) {
|
||||||
var transcludeScope = scope.$new();
|
var transcludeScope = scope.$new();
|
||||||
|
transcludeScope.$$transcluded = true;
|
||||||
|
|
||||||
return transcludeFn(transcludeScope, cloneFn).
|
return transcludeFn(transcludeScope, cloneFn).
|
||||||
bind('$destroy', bind(transcludeScope, transcludeScope.$destroy));
|
bind('$destroy', bind(transcludeScope, transcludeScope.$destroy));
|
||||||
|
|
@ -725,6 +726,8 @@ function $CompileProvider($provide) {
|
||||||
lastValue,
|
lastValue,
|
||||||
parentGet, parentSet;
|
parentGet, parentSet;
|
||||||
|
|
||||||
|
scope.$$isolateBindings[scopeName] = mode + attrName;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|
||||||
case '@': {
|
case '@': {
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,7 @@ function $RootScopeProvider(){
|
||||||
this.$$destroyed = false;
|
this.$$destroyed = false;
|
||||||
this.$$asyncQueue = [];
|
this.$$asyncQueue = [];
|
||||||
this.$$listeners = {};
|
this.$$listeners = {};
|
||||||
|
this.$$isolateBindings = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1938,6 +1938,21 @@ describe('$compile', function() {
|
||||||
compile('<div><span bad-declaration>');
|
compile('<div><span bad-declaration>');
|
||||||
}).toThrow('Invalid isolate scope definition for directive badDeclaration: xxx');
|
}).toThrow('Invalid isolate scope definition for directive badDeclaration: xxx');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should expose a $$isolateBindings property onto the scope', inject(function() {
|
||||||
|
compile('<div><span my-component>');
|
||||||
|
|
||||||
|
expect(typeof componentScope.$$isolateBindings).toBe('object');
|
||||||
|
|
||||||
|
expect(componentScope.$$isolateBindings.attr).toBe('@attr');
|
||||||
|
expect(componentScope.$$isolateBindings.attrAlias).toBe('@attr');
|
||||||
|
expect(componentScope.$$isolateBindings.ref).toBe('=ref');
|
||||||
|
expect(componentScope.$$isolateBindings.refAlias).toBe('=ref');
|
||||||
|
expect(componentScope.$$isolateBindings.reference).toBe('=reference');
|
||||||
|
expect(componentScope.$$isolateBindings.expr).toBe('&expr');
|
||||||
|
expect(componentScope.$$isolateBindings.exprAlias).toBe('&expr');
|
||||||
|
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2264,5 +2279,28 @@ describe('$compile', function() {
|
||||||
|
|
||||||
expect(element.text()).toBe('-->|x|');
|
expect(element.text()).toBe('-->|x|');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should add a $$transcluded property onto the transcluded scope', function() {
|
||||||
|
module(function() {
|
||||||
|
directive('trans', function() {
|
||||||
|
return {
|
||||||
|
transclude: true,
|
||||||
|
replace: true,
|
||||||
|
scope: true,
|
||||||
|
template: '<div><span>I:{{$$transcluded}}</span><div ng-transclude></div></div>'
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
inject(function(log, $rootScope, $compile) {
|
||||||
|
element = $compile('<div><div trans>T:{{$$transcluded}}</div></div>')
|
||||||
|
($rootScope);
|
||||||
|
$rootScope.$apply();
|
||||||
|
expect(jqLite(element.find('span')[0]).text()).toEqual('I:');
|
||||||
|
expect(jqLite(element.find('span')[1]).text()).toEqual('T:true');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue