diff --git a/src/components/img-loader.ts b/src/components/img-loader.ts index 0b36500..4203b3e 100644 --- a/src/components/img-loader.ts +++ b/src/components/img-loader.ts @@ -1,4 +1,4 @@ -import { Component, Input, Output, ElementRef, Renderer2, OnInit, EventEmitter } from '@angular/core'; +import { Component, Input, Output, ElementRef, Renderer, OnInit, EventEmitter } from '@angular/core'; import { ImageLoader } from '../providers/image-loader'; import { ImageLoaderConfig } from '../providers/image-loader-config'; @@ -124,7 +124,7 @@ export class ImgLoader implements OnInit { constructor( private _element: ElementRef, - private _renderer: Renderer2, + private _renderer: Renderer, private _imageLoader: ImageLoader, private _config: ImageLoaderConfig ) {} @@ -191,16 +191,15 @@ export class ImgLoader implements OnInit { // Using tag if (!this.element) { // create img element if we dont have one - this.element = this._renderer.createElement('img'); - this._renderer.appendChild(this._element.nativeElement, this.element); + this.element = this._renderer.createElement(this._element.nativeElement, 'img'); } // set it's src - this._renderer.setAttribute(this.element, 'src', imageUrl); + this._renderer.setElementAttribute(this.element, 'src', imageUrl); if (this.fallbackUrl && !this._imageLoader.nativeAvailable) { - this._renderer.listen(this.element, 'error', () => this._renderer.setAttribute(this.element, 'src', this.fallbackUrl)); + this._renderer.listen(this.element, 'error', () => this._renderer.setElementAttribute(this.element, 'src', this.fallbackUrl)); } } else { @@ -211,11 +210,11 @@ export class ImgLoader implements OnInit { for (let prop in propMap) { if (this[prop]) { - this._renderer.setStyle(this.element, propMap[prop], this[prop]); + this._renderer.setElementStyle(this.element, propMap[prop], this[prop]); } } - this._renderer.setStyle(this.element, 'background-image', 'url(\'' + ( imageUrl || this.fallbackUrl ) + '\')'); + this._renderer.setElementStyle(this.element, 'background-image', 'url(\'' + ( imageUrl || this.fallbackUrl ) + '\')'); } this.load.emit(this);