diff options
| author | Brian Ford | 2013-01-23 00:01:13 -0500 |
|---|---|---|
| committer | Brian Ford | 2013-01-30 10:42:56 -0500 |
| commit | 649b892205615a144dafff9984c0e6ab10ed341d (patch) | |
| tree | e497a02b8714e0a4959d5d366a4a3104a9470e30 | |
| parent | e0295cfec4e54246f64e9daecb764454e6e6b071 (diff) | |
| download | angular.js-649b892205615a144dafff9984c0e6ab10ed341d.tar.bz2 | |
feat(Scope): expose transcluded and isolate scope info for batarang
test($compile): add test for exposing transclude and isolate scope info to batarang
| -rw-r--r-- | src/ng/compile.js | 3 | ||||
| -rw-r--r-- | src/ng/rootScope.js | 1 | ||||
| -rw-r--r-- | test/ng/compileSpec.js | 38 |
3 files changed, 42 insertions, 0 deletions
diff --git a/src/ng/compile.js b/src/ng/compile.js index 84d53e6d..13f8ae7e 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -420,6 +420,7 @@ function $CompileProvider($provide) { (function(transcludeFn) { return function(cloneFn) { var transcludeScope = scope.$new(); + transcludeScope.$$transcluded = true; return transcludeFn(transcludeScope, cloneFn). bind('$destroy', bind(transcludeScope, transcludeScope.$destroy)); @@ -725,6 +726,8 @@ function $CompileProvider($provide) { lastValue, parentGet, parentSet; + scope.$$isolateBindings[scopeName] = mode + attrName; + switch (mode) { case '@': { diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index 9be37b9f..549517b6 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -137,6 +137,7 @@ function $RootScopeProvider(){ this.$$destroyed = false; this.$$asyncQueue = []; this.$$listeners = {}; + this.$$isolateBindings = {}; } /** diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 363b4329..b4ec0292 100644 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -1938,6 +1938,21 @@ describe('$compile', function() { compile('<div><span bad-declaration>'); }).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|'); })); + + + 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'); + }); + }); + + }); }); |
