| 
									
										
										
										
											2016-06-23 09:47:54 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-28 11:20:01 -07:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2016-04-13 17:05:17 -07:00
										 |  |  |  * A wrapper around a native element inside of a View. | 
					
						
							| 
									
										
										
										
											2015-09-18 15:46:26 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-09-21 12:32:25 -07:00
										 |  |  |  * An `ElementRef` is backed by a render-specific element. In the browser, this is usually a DOM | 
					
						
							|  |  |  |  * element. | 
					
						
							| 
									
										
										
										
											2016-06-27 12:27:23 -07:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2016-06-28 11:01:35 -07:00
										 |  |  |  * @security Permitting direct access to the DOM can make your application more vulnerable to | 
					
						
							|  |  |  |  * XSS attacks. Carefully review any use of `ElementRef` in your code. For more detail, see the | 
					
						
							|  |  |  |  * [Security Guide](http://g.co/ng/security).
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2016-06-27 12:27:23 -07:00
										 |  |  |  * @stable | 
					
						
							| 
									
										
										
										
											2015-04-28 11:20:01 -07:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-04-13 17:05:17 -07:00
										 |  |  | // Note: We don't expose things like `Injector`, `ViewContainer`, ... here,
 | 
					
						
							|  |  |  | // i.e. users have to ask for what they need. With that, we can build better analysis tools
 | 
					
						
							|  |  |  | // and could do better codegen in the future.
 | 
					
						
							| 
									
										
										
										
											2017-12-03 20:17:06 +01:00
										 |  |  | export class ElementRef<T = any> { | 
					
						
							| 
									
										
										
										
											2015-04-28 11:20:01 -07:00
										 |  |  |   /** | 
					
						
							| 
									
										
										
										
											2015-09-18 15:46:26 -07:00
										 |  |  |    * The underlying native element or `null` if direct access to native elements is not supported | 
					
						
							|  |  |  |    * (e.g. when the application runs in a web worker). | 
					
						
							| 
									
										
										
										
											2015-07-07 08:15:58 +02:00
										 |  |  |    * | 
					
						
							| 
									
										
										
										
											2015-09-18 15:46:26 -07:00
										 |  |  |    * <div class="callout is-critical"> | 
					
						
							|  |  |  |    *   <header>Use with caution</header> | 
					
						
							|  |  |  |    *   <p> | 
					
						
							| 
									
										
										
										
											2015-09-28 19:58:38 -07:00
										 |  |  |    *    Use this API as the last resort when direct access to DOM is needed. Use templating and | 
					
						
							| 
									
										
										
										
											2017-11-15 11:42:01 -08:00
										 |  |  |    *    data-binding provided by Angular instead. Alternatively you can take a look at {@link | 
					
						
							|  |  |  |    * Renderer2} | 
					
						
							|  |  |  |    *    which provides API that can safely be used even when direct access to native elements is not | 
					
						
							|  |  |  |    *    supported. | 
					
						
							| 
									
										
										
										
											2015-09-18 15:46:26 -07:00
										 |  |  |    *   </p> | 
					
						
							|  |  |  |    *   <p> | 
					
						
							|  |  |  |    *    Relying on direct DOM access creates tight coupling between your application and rendering | 
					
						
							| 
									
										
										
										
											2015-09-21 12:32:25 -07:00
										 |  |  |    *    layers which will make it impossible to separate the two and deploy your application into a | 
					
						
							| 
									
										
										
										
											2015-09-18 15:46:26 -07:00
										 |  |  |    *    web worker. | 
					
						
							|  |  |  |    *   </p> | 
					
						
							|  |  |  |    * </div> | 
					
						
							| 
									
										
										
										
											2016-05-25 15:00:05 -07:00
										 |  |  |    * @stable | 
					
						
							| 
									
										
										
										
											2015-04-28 11:20:01 -07:00
										 |  |  |    */ | 
					
						
							| 
									
										
										
										
											2017-12-03 20:17:06 +01:00
										 |  |  |   public nativeElement: T; | 
					
						
							| 
									
										
										
										
											2015-10-06 06:53:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-03 20:17:06 +01:00
										 |  |  |   constructor(nativeElement: T) { this.nativeElement = nativeElement; } | 
					
						
							| 
									
										
										
										
											2015-04-28 11:20:01 -07:00
										 |  |  | } |