Content-Length: 412805 | pFad | https://github.com/angular/angular/commit/785a1110e603a3573261528f2fda28718f548b4a

66 fix(common): resolve host binding type issues (#60481) · angular/angular@785a111 · GitHub
Skip to content

Commit 785a111

Browse files
crisbetoalxhub
authored andcommitted
fix(common): resolve host binding type issues (#60481)
Fixes type issues in the host bindings of `NgOptimizedImage`. PR Close #60481
1 parent e301471 commit 785a111

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

goldens/public-api/common/index.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ export class NgOptimizedImage implements OnInit, OnChanges {
605605
constructor();
606606
disableOptimizedSrcset: boolean;
607607
fill: boolean;
608+
protected generatePlaceholder(placeholderInput: string | boolean): string | boolean | null;
608609
height: number | undefined;
609610
loaderParams?: {
610611
[key: string]: any;
@@ -633,6 +634,7 @@ export class NgOptimizedImage implements OnInit, OnChanges {
633634
placeholder?: string | boolean;
634635
placeholderConfig?: ImagePlaceholderConfig;
635636
priority: boolean;
637+
protected shouldBlurPlaceholder(placeholderConfig?: ImagePlaceholderConfig): boolean;
636638
sizes?: string;
637639
width: number | undefined;
638640
// (undocumented)

packages/common/src/directives/ng_optimized_image/ng_optimized_image.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ const OVERSIZED_IMAGE_TOLERANCE = 1000;
111111
const FIXED_SRCSET_WIDTH_LIMIT = 1920;
112112
const FIXED_SRCSET_HEIGHT_LIMIT = 1080;
113113

114-
/**
115-
* Default blur radius of the CSS filter used on placeholder images, in pixels
116-
*/
117-
export const PLACEHOLDER_BLUR_AMOUNT = 15;
118-
119114
/**
120115
* Placeholder dimension (height or width) limit in pixels. Angular produces a warning
121116
* when this limit is crossed.
@@ -279,7 +274,8 @@ export interface ImagePlaceholderConfig {
279274
'[style.background-position]': 'placeholder ? "50% 50%" : null',
280275
'[style.background-repeat]': 'placeholder ? "no-repeat" : null',
281276
'[style.background-image]': 'placeholder ? generatePlaceholder(placeholder) : null',
282-
'[style.filter]': `placeholder && shouldBlurPlaceholder(placeholderConfig) ? "blur(${PLACEHOLDER_BLUR_AMOUNT}px)" : null`,
277+
'[style.filter]':
278+
'placeholder && shouldBlurPlaceholder(placeholderConfig) ? "blur(15px)" : null',
283279
},
284280
})
285281
export class NgOptimizedImage implements OnInit, OnChanges {
@@ -687,7 +683,7 @@ export class NgOptimizedImage implements OnInit, OnChanges {
687683
* * A base64 encoded image, which is wrapped and passed through.
688684
* * A boolean. If true, calls the image loader to generate a small placeholder url.
689685
*/
690-
private generatePlaceholder(placeholderInput: string | boolean): string | boolean | null {
686+
protected generatePlaceholder(placeholderInput: string | boolean): string | boolean | null {
691687
const {placeholderResolution} = this.config;
692688
if (placeholderInput === true) {
693689
return `url(${this.callImageLoader({
@@ -705,7 +701,7 @@ export class NgOptimizedImage implements OnInit, OnChanges {
705701
* Determines if blur should be applied, based on an optional boolean
706702
* property `blur` within the optional configuration object `placeholderConfig`.
707703
*/
708-
private shouldBlurPlaceholder(placeholderConfig?: ImagePlaceholderConfig): boolean {
704+
protected shouldBlurPlaceholder(placeholderConfig?: ImagePlaceholderConfig): boolean {
709705
if (!placeholderConfig || !placeholderConfig.hasOwnProperty('blur')) {
710706
return true;
711707
}

packages/common/test/directives/ng_optimized_image_spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ import {
2828
DATA_URL_ERROR_LIMIT,
2929
DATA_URL_WARN_LIMIT,
3030
NgOptimizedImage,
31-
PLACEHOLDER_BLUR_AMOUNT,
3231
RECOMMENDED_SRCSET_DENSITY_CAP,
3332
resetImagePriorityCount,
3433
} from '../../src/directives/ng_optimized_image/ng_optimized_image';
3534
import {PRECONNECT_CHECK_BLOCKLIST} from '../../src/directives/ng_optimized_image/preconnect_link_checker';
3635

3736
describe('Image directive', () => {
37+
const PLACEHOLDER_BLUR_AMOUNT = 15;
38+
3839
describe('preload <link> element on a server', () => {
3940
describe('server', () => {
4041
beforeEach(() => {

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/angular/angular/commit/785a1110e603a3573261528f2fda28718f548b4a

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy