@ibragim-dev-org/ui-forge-library 1.2.8 → 1.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -239,21 +239,22 @@ class LazyImgDirective {
239
239
  lazySrc;
240
240
  loadError = new EventEmitter();
241
241
  observer;
242
+ onError = () => {
243
+ this.loadError.emit();
244
+ };
242
245
  constructor(el, lazyService) {
243
246
  this.el = el;
244
247
  this.lazyService = lazyService;
245
248
  }
246
- onError() {
247
- this.loadError.emit();
248
- }
249
249
  ngOnInit() {
250
250
  const img = this.el.nativeElement;
251
- if (!this.lazySrc || this.lazySrc.trim().length === 0) {
251
+ const lazySrc = this.lazySrc?.trim() ?? '';
252
+ if (lazySrc.length === 0 || /(?:^|\/)null(?:[?#].*)?$/i.test(lazySrc)) {
252
253
  this.loadError.emit();
253
254
  return;
254
255
  }
255
256
  img.addEventListener('error', this.onError);
256
- img.setAttribute('data-src', this.lazySrc);
257
+ img.setAttribute('data-src', lazySrc);
257
258
  this.observer = this.lazyService.getObserver();
258
259
  this.observer.observe(img);
259
260
  }