build: reformat repo to new clang@1.4.0 (#36613)

PR Close #36613
This commit is contained in:
Joey Perrott
2020-04-13 16:40:21 -07:00
committed by atscott
parent 5e80e7e216
commit 698b0288be
1160 changed files with 31667 additions and 24000 deletions

View File

@ -7,7 +7,7 @@
*/
import {ApplicationRef, ComponentFactory, ComponentFactoryResolver, ComponentRef, EventEmitter, Injector, OnChanges, SimpleChange, SimpleChanges, Type} from '@angular/core';
import {Observable, merge} from 'rxjs';
import {merge, Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {NgElementStrategy, NgElementStrategyEvent, NgElementStrategyFactory} from './element-strategy';
@ -45,11 +45,11 @@ export class ComponentNgElementStrategyFactory implements NgElementStrategyFacto
export class ComponentNgElementStrategy implements NgElementStrategy {
/** Merged stream of the component's output events. */
// TODO(issue/24571): remove '!'.
events !: Observable<NgElementStrategyEvent>;
events!: Observable<NgElementStrategyEvent>;
/** Reference to the component that was created on connect. */
// TODO(issue/24571): remove '!'.
private componentRef !: ComponentRef<any>| null;
private componentRef!: ComponentRef<any>|null;
/** Changes that have been made to the component ref since the last time onChanges was called. */
private inputChanges: SimpleChanges|null = null;
@ -105,7 +105,7 @@ export class ComponentNgElementStrategy implements NgElementStrategy {
// moved elsewhere in the DOM
this.scheduledDestroyFn = scheduler.schedule(() => {
if (this.componentRef) {
this.componentRef !.destroy();
this.componentRef!.destroy();
this.componentRef = null;
}
}, DESTROY_DELAY);
@ -190,7 +190,7 @@ export class ComponentNgElementStrategy implements NgElementStrategy {
/** Sets up listeners for the component's outputs so that the events stream emits the events. */
protected initializeOutputs(): void {
const eventEmitters = this.componentFactory.outputs.map(({propName, templateName}) => {
const emitter = (this.componentRef !.instance as any)[propName] as EventEmitter<any>;
const emitter = (this.componentRef!.instance as any)[propName] as EventEmitter<any>;
return emitter.pipe(map((value: any) => ({name: templateName, value})));
});
@ -207,7 +207,7 @@ export class ComponentNgElementStrategy implements NgElementStrategy {
// during ngOnChanges.
const inputChanges = this.inputChanges;
this.inputChanges = null;
(this.componentRef !.instance as any as OnChanges).ngOnChanges(inputChanges);
(this.componentRef!.instance as any as OnChanges).ngOnChanges(inputChanges);
}
/**
@ -260,6 +260,6 @@ export class ComponentNgElementStrategy implements NgElementStrategy {
}
this.callNgOnChanges();
this.componentRef !.changeDetectorRef.detectChanges();
this.componentRef!.changeDetectorRef.detectChanges();
}
}

View File

@ -31,7 +31,7 @@ export interface NgElementConstructor<P> {
* Initializes a constructor instance.
* @param injector If provided, overrides the configured injector.
*/
new (injector?: Injector): NgElement&WithProperties<P>;
new(injector?: Injector): NgElement&WithProperties<P>;
}
/**
@ -44,20 +44,20 @@ export abstract class NgElement extends HTMLElement {
* The strategy that controls how a component is transformed in a custom element.
*/
// TODO(issue/24571): remove '!'.
protected ngElementStrategy !: NgElementStrategy;
protected ngElementStrategy!: NgElementStrategy;
/**
* A subscription to change, connect, and disconnect events in the custom element.
*/
protected ngElementEventsSubscription: Subscription|null = null;
/**
* Prototype for a handler that responds to a change in an observed attribute.
* @param attrName The name of the attribute that has changed.
* @param oldValue The previous value of the attribute.
* @param newValue The new value of the attribute.
* @param namespace The namespace in which the attribute is defined.
* @returns Nothing.
*/
* Prototype for a handler that responds to a change in an observed attribute.
* @param attrName The name of the attribute that has changed.
* @param oldValue The previous value of the attribute.
* @param newValue The new value of the attribute.
* @param namespace The namespace in which the attribute is defined.
* @returns Nothing.
*/
abstract attributeChangedCallback(
attrName: string, oldValue: string|null, newValue: string, namespace?: string): void;
/**
@ -152,7 +152,7 @@ export function createCustomElement<P>(
this.ngElementStrategy = strategyFactory.create(config.injector);
}
const propName = attributeToPropertyInputs[attrName] !;
const propName = attributeToPropertyInputs[attrName]!;
this.ngElementStrategy.setInputValue(propName, newValue);
}
@ -165,7 +165,7 @@ export function createCustomElement<P>(
// Listen for events from the strategy and dispatch them as custom events
this.ngElementEventsSubscription = this.ngElementStrategy.events.subscribe(e => {
const customEvent = createCustomEvent(this.ownerDocument !, e.name, e.value);
const customEvent = createCustomEvent(this.ownerDocument!, e.name, e.value);
this.dispatchEvent(customEvent);
});
}
@ -186,8 +186,12 @@ export function createCustomElement<P>(
// contain property inputs, use all inputs by default.
inputs.map(({propName}) => propName).forEach(property => {
Object.defineProperty(NgElementImpl.prototype, property, {
get: function() { return this.ngElementStrategy.getInputValue(property); },
set: function(newValue: any) { this.ngElementStrategy.setInputValue(property, newValue); },
get: function() {
return this.ngElementStrategy.getInputValue(property);
},
set: function(newValue: any) {
this.ngElementStrategy.setInputValue(property, newValue);
},
configurable: true,
enumerable: true,
});

View File

@ -22,8 +22,10 @@ export const scheduler = {
*
* Returns a function that when executed will cancel the scheduled function.
*/
schedule(taskFn: () => void, delay: number): () =>
void{const id = setTimeout(taskFn, delay); return () => clearTimeout(id);},
schedule(taskFn: () => void, delay: number): () => void {
const id = setTimeout(taskFn, delay);
return () => clearTimeout(id);
},
/**
* Schedule a callback to be called before the next render.
@ -31,7 +33,7 @@ export const scheduler = {
*
* Returns a function that when executed will cancel the scheduled function.
*/
scheduleBeforeRender(taskFn: () => void): () => void{
scheduleBeforeRender(taskFn: () => void): () => void {
// TODO(gkalpak): Implement a better way of accessing `requestAnimationFrame()`
// (e.g. accounting for vendor prefix, SSR-compatibility, etc).
if (typeof window === 'undefined') {
@ -76,7 +78,7 @@ export function createCustomEvent(doc: Document, name: string, detail: any): Cus
/**
* Check whether the input is an `Element`.
*/
export function isElement(node: Node | null): node is Element {
export function isElement(node: Node|null): node is Element {
return !!node && node.nodeType === Node.ELEMENT_NODE;
}