| 300 | } |
| 301 | |
| 302 | class DefaultDomRenderer2 implements Renderer2 { |
| 303 | data: {[key: string]: any} = Object.create(null); |
| 304 | |
| 305 | /** |
| 306 | * By default this renderer throws when encountering synthetic properties |
| 307 | * This can be disabled for example by the AsyncAnimationRendererFactory |
| 308 | */ |
| 309 | throwOnSyntheticProps = true; |
| 310 | |
| 311 | constructor( |
| 312 | private readonly eventManager: EventManager, |
| 313 | private readonly doc: Document, |
| 314 | protected readonly ngZone: NgZone, |
| 315 | private readonly tracingService: TracingService<TracingSnapshot> | null, |
| 316 | private readonly cssVarNamespace: string = '', |
| 317 | ) {} |
| 318 | |
| 319 | destroy(): void {} |
| 320 | |
| 321 | destroyNode = null; |
| 322 | |
| 323 | createElement(name: string, namespace?: string): any { |
| 324 | if (namespace) { |
| 325 | // TODO: `|| namespace` was added in |
| 326 | // https://github.com/angular/angular/commit/2b9cc8503d48173492c29f5a271b61126104fbdb to |
| 327 | // support how Ivy passed around the namespace URI rather than short name at the time. It did |
| 328 | // not, however extend the support to other parts of the system (setAttribute, setAttribute, |
| 329 | // and the ServerRenderer). We should decide what exactly the semantics for dealing with |
| 330 | // namespaces should be and make it consistent. |
| 331 | // Related issues: |
| 332 | // https://github.com/angular/angular/issues/44028 |
| 333 | // https://github.com/angular/angular/issues/44883 |
| 334 | return this.doc.createElementNS(NAMESPACE_URIS[namespace] || namespace, name); |
| 335 | } |
| 336 | |
| 337 | return this.doc.createElement(name); |
| 338 | } |
| 339 | |
| 340 | createComment(value: string): any { |
| 341 | return this.doc.createComment(value); |
| 342 | } |
| 343 | |
| 344 | createText(value: string): any { |
| 345 | return this.doc.createTextNode(value); |
| 346 | } |
| 347 | |
| 348 | appendChild(parent: any, newChild: any): void { |
| 349 | const targetParent = isTemplateNode(parent) ? parent.content : parent; |
| 350 | targetParent.appendChild(newChild); |
| 351 | } |
| 352 | |
| 353 | insertBefore(parent: any, newChild: any, refChild: any): void { |
| 354 | if (parent) { |
| 355 | const targetParent = isTemplateNode(parent) ? parent.content : parent; |
| 356 | // If something outside Angular removed or moved `refChild` (a browser extension, for |
| 357 | // example), the native call below throws a `NotFoundError` with no useful info. Catch it |
| 358 | // here so we can say what actually happened. |
| 359 | if (refChild != null && refChild.parentNode !== targetParent) { |