mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(common): improve image directive typings
Add image directive typings to improve type safety and removes an unused parameter from the observer registration.
This commit is contained in:
parent
5b59dbd36f
commit
ddfc833df9
3 changed files with 5 additions and 5 deletions
|
|
@ -639,7 +639,7 @@ export class NgOptimizedImage implements OnInit, OnChanges {
|
|||
static ngAcceptInputType_priority: unknown;
|
||||
// (undocumented)
|
||||
static ngAcceptInputType_width: unknown;
|
||||
ngOnChanges(changes: SimpleChanges): void;
|
||||
ngOnChanges(changes: SimpleChanges<NgOptimizedImage>): void;
|
||||
ngOnInit(): void;
|
||||
ngSrc: string;
|
||||
ngSrcset: string;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ export class LCPImageObserver implements OnDestroy {
|
|||
return observer;
|
||||
}
|
||||
|
||||
registerImage(rewrittenSrc: string, originalNgSrc: string, isPriority: boolean) {
|
||||
registerImage(rewrittenSrc: string, isPriority: boolean) {
|
||||
if (!this.observer) return;
|
||||
const newObservedImageState: ObservedImageState = {
|
||||
priority: isPriority,
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ export class NgOptimizedImage implements OnInit, OnChanges {
|
|||
/**
|
||||
* Calculate the rewritten `src` once and store it.
|
||||
* This is needed to avoid repetitive calculations and make sure the directive cleanup in the
|
||||
* `ngOnDestroy` does not rely on the `IMAGE_LOADER` logic (which in turn can rely on some other
|
||||
* `DestroyRef.onDestroy` does not rely on the `IMAGE_LOADER` logic (which in turn can rely on some other
|
||||
* instance that might be already destroyed).
|
||||
*/
|
||||
private _renderedSrc: string | null = null;
|
||||
|
|
@ -454,7 +454,7 @@ export class NgOptimizedImage implements OnInit, OnChanges {
|
|||
assertNoLoaderParamsWithoutLoader(this, this.imageLoader);
|
||||
|
||||
ngZone.runOutsideAngular(() => {
|
||||
this.lcpObserver!.registerImage(this.getRewrittenSrc(), this.ngSrc, this.priority);
|
||||
this.lcpObserver!.registerImage(this.getRewrittenSrc(), this.priority);
|
||||
});
|
||||
|
||||
if (this.priority) {
|
||||
|
|
@ -523,7 +523,7 @@ export class NgOptimizedImage implements OnInit, OnChanges {
|
|||
}
|
||||
|
||||
/** @docs-private */
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
ngOnChanges(changes: SimpleChanges<NgOptimizedImage>) {
|
||||
if (ngDevMode) {
|
||||
assertNoPostInitInputChange(this, changes, [
|
||||
'ngSrcset',
|
||||
|
|
|
|||
Loading…
Reference in a new issue