parent
							
								
									7e93c54603
								
							
						
					
					
						commit
						0d1dece7b4
					
				| @ -173,6 +173,10 @@ class BrowserDomAdapter extends DomAdapter { | ||||
|       document.implementation.createHtmlDocument('fakeTitle'); | ||||
| 
 | ||||
|   HtmlDocument defaultDoc() => document; | ||||
|   String getTitle() => document.title; | ||||
|   void setTitle(String newTitle) { | ||||
|     document.title = newTitle; | ||||
|   } | ||||
|   bool elementMatches(n, String selector) => | ||||
|       n is Element && n.matches(selector); | ||||
|   bool isTemplateElement(Element el) => | ||||
|  | ||||
| @ -215,6 +215,12 @@ export class BrowserDomAdapter extends DomAdapter { | ||||
|   defaultDoc() { | ||||
|     return document; | ||||
|   } | ||||
|   getTitle() { | ||||
|     return document.title; | ||||
|   } | ||||
|   setTitle(newTitle:string) { | ||||
|     document.title = newTitle; | ||||
|   } | ||||
|   elementMatches(n, selector:string):boolean { | ||||
|     return n instanceof HTMLElement && n.matches(selector); | ||||
|   } | ||||
|  | ||||
							
								
								
									
										6
									
								
								modules/angular2/src/dom/dom_adapter.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								modules/angular2/src/dom/dom_adapter.js
									
									
									
									
										vendored
									
									
								
							| @ -201,6 +201,12 @@ export class DomAdapter { | ||||
|   defaultDoc() { | ||||
|     throw _abstract(); | ||||
|   } | ||||
|   getTitle() { | ||||
|     throw _abstract(); | ||||
|   } | ||||
|   setTitle(newTitle:string) { | ||||
|     throw _abstract(); | ||||
|   } | ||||
|   elementMatches(n, selector:string):boolean { | ||||
|     throw _abstract(); | ||||
|   } | ||||
|  | ||||
							
								
								
									
										12
									
								
								modules/angular2/src/services/title.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								modules/angular2/src/services/title.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| import {DOM} from 'angular2/src/dom/dom_adapter'; | ||||
| 
 | ||||
| export class Title { | ||||
| 
 | ||||
|   getTitle():string { | ||||
|     return DOM.getTitle(); | ||||
|   } | ||||
| 
 | ||||
|   setTitle(newTitle:string) { | ||||
|     DOM.setTitle(newTitle); | ||||
|   } | ||||
| } | ||||
							
								
								
									
										32
									
								
								modules/angular2/test/services/title_spec.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								modules/angular2/test/services/title_spec.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| import {ddescribe, describe, it, iit, xit, expect, afterEach} from 'angular2/test_lib'; | ||||
| import {DOM} from 'angular2/src/dom/dom_adapter'; | ||||
| 
 | ||||
| import {Title} from 'angular2/src/services/title'; | ||||
| 
 | ||||
| export function main() { | ||||
| 
 | ||||
|   describe('title service', () => { | ||||
|     var initialTitle = DOM.getTitle(); | ||||
|     var titleService = new Title(); | ||||
| 
 | ||||
|     afterEach(() => { | ||||
|       DOM.setTitle(initialTitle); | ||||
|     }); | ||||
| 
 | ||||
|     it('should allow reading initial title', () => { | ||||
|       expect(titleService.getTitle()).toEqual(initialTitle); | ||||
|     }); | ||||
| 
 | ||||
|     it('should set a title on the injected document', () => { | ||||
|       titleService.setTitle('test title'); | ||||
|       expect(DOM.getTitle()).toEqual('test title'); | ||||
|       expect(titleService.getTitle()).toEqual('test title'); | ||||
|     }); | ||||
| 
 | ||||
|     it('should reset title to empty string if title not provided', () => { | ||||
|       titleService.setTitle(null); | ||||
|       expect(DOM.getTitle()).toEqual(''); | ||||
|     }); | ||||
| 
 | ||||
|   }); | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user