| 
									
										
										
										
											2015-03-13 11:10:11 +01:00
										 |  |  | import { | 
					
						
							|  |  |  |   AsyncTestCompleter, | 
					
						
							|  |  |  |   beforeEach, | 
					
						
							|  |  |  |   ddescribe, | 
					
						
							|  |  |  |   describe, | 
					
						
							|  |  |  |   el, | 
					
						
							|  |  |  |   expect, | 
					
						
							|  |  |  |   iit, | 
					
						
							|  |  |  |   inject, | 
					
						
							|  |  |  |   it, | 
					
						
							|  |  |  |   xit, | 
					
						
							|  |  |  | } from 'angular2/test_lib'; | 
					
						
							| 
									
										
										
										
											2015-02-27 14:50:06 -08:00
										 |  |  | import {DOM} from 'angular2/src/dom/dom_adapter'; | 
					
						
							| 
									
										
										
										
											2015-02-24 16:05:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-30 13:38:40 -07:00
										 |  |  | import {Directive, Component} from 'angular2/src/core/annotations_impl/annotations'; | 
					
						
							| 
									
										
										
										
											2015-04-28 18:17:00 -07:00
										 |  |  | import {View} from 'angular2/src/core/annotations_impl/view'; | 
					
						
							| 
									
										
										
										
											2015-02-24 16:05:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-28 11:20:01 -07:00
										 |  |  | import {ElementRef} from 'angular2/src/core/compiler/element_ref'; | 
					
						
							| 
									
										
										
										
											2015-03-30 17:11:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-13 10:11:33 +02:00
										 |  |  | import {NgNonBindable} from 'angular2/src/directives/ng_non_bindable'; | 
					
						
							| 
									
										
										
										
											2015-03-30 17:11:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | import {TestBed} from 'angular2/src/test_lib/test_bed'; | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							| 
									
										
										
										
											2015-02-04 22:27:31 +01:00
										 |  |  |   describe('non-bindable', () => { | 
					
						
							| 
									
										
										
										
											2015-03-30 17:11:18 +02:00
										 |  |  |     it('should not interpolate children', inject([TestBed, AsyncTestCompleter], (tb, async) => { | 
					
						
							| 
									
										
										
										
											2015-05-11 16:00:53 -07:00
										 |  |  |       var template = '<div>{{text}}<span ng-non-bindable>{{text}}</span></div>'; | 
					
						
							| 
									
										
										
										
											2015-03-30 17:11:18 +02:00
										 |  |  |       tb.createView(TestComponent, {html: template}).then((view) => { | 
					
						
							|  |  |  |         view.detectChanges(); | 
					
						
							| 
									
										
										
										
											2015-04-07 20:54:20 -07:00
										 |  |  |         expect(DOM.getText(view.rootNodes[0])).toEqual('foo{{text}}'); | 
					
						
							| 
									
										
										
										
											2015-03-13 11:10:11 +01:00
										 |  |  |         async.done(); | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-03-13 11:10:11 +01:00
										 |  |  |     })); | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-30 17:11:18 +02:00
										 |  |  |     it('should ignore directives on child nodes', inject([TestBed, AsyncTestCompleter], (tb, async) => { | 
					
						
							| 
									
										
										
										
											2015-05-11 16:00:53 -07:00
										 |  |  |       var template = '<div ng-non-bindable><span id=child test-dec>{{text}}</span></div>'; | 
					
						
							| 
									
										
										
										
											2015-03-30 17:11:18 +02:00
										 |  |  |       tb.createView(TestComponent, {html: template}).then((view) => { | 
					
						
							|  |  |  |         view.detectChanges(); | 
					
						
							| 
									
										
										
										
											2015-04-07 20:54:20 -07:00
										 |  |  |         var span = DOM.querySelector(view.rootNodes[0], '#child'); | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  |         expect(DOM.hasClass(span, 'compiled')).toBeFalsy(); | 
					
						
							| 
									
										
										
										
											2015-03-13 11:10:11 +01:00
										 |  |  |         async.done(); | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-03-13 11:10:11 +01:00
										 |  |  |     })); | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-30 17:11:18 +02:00
										 |  |  |     it('should trigger directives on the same node', inject([TestBed, AsyncTestCompleter], (tb, async) => { | 
					
						
							| 
									
										
										
										
											2015-05-11 16:00:53 -07:00
										 |  |  |       var template = '<div><span id=child ng-non-bindable test-dec>{{text}}</span></div>'; | 
					
						
							| 
									
										
										
										
											2015-03-30 17:11:18 +02:00
										 |  |  |       tb.createView(TestComponent, {html: template}).then((view) => { | 
					
						
							|  |  |  |         view.detectChanges(); | 
					
						
							| 
									
										
										
										
											2015-04-07 20:54:20 -07:00
										 |  |  |         var span = DOM.querySelector(view.rootNodes[0], '#child'); | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  |         expect(DOM.hasClass(span, 'compiled')).toBeTruthy(); | 
					
						
							| 
									
										
										
										
											2015-03-13 11:10:11 +01:00
										 |  |  |         async.done(); | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-03-13 11:10:11 +01:00
										 |  |  |     })); | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  |   }) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-12 14:44:59 +01:00
										 |  |  | @Component({selector: 'test-cmp'}) | 
					
						
							| 
									
										
										
										
											2015-05-11 16:00:53 -07:00
										 |  |  | @View({directives: [NgNonBindable, TestDirective]}) | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  | class TestComponent { | 
					
						
							|  |  |  |   text: string; | 
					
						
							|  |  |  |   constructor() { | 
					
						
							|  |  |  |     this.text = 'foo'; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-30 13:38:40 -07:00
										 |  |  | @Directive({ | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  |   selector: '[test-dec]' | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2015-04-30 13:38:40 -07:00
										 |  |  | class TestDirective { | 
					
						
							| 
									
										
										
										
											2015-04-28 11:20:01 -07:00
										 |  |  |   constructor(el: ElementRef) { | 
					
						
							| 
									
										
										
										
											2015-01-08 13:57:41 +01:00
										 |  |  |     DOM.addClass(el.domElement, 'compiled'); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |