Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lazyimg

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazyimg - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

2

package.json
{
"name": "lazyimg",
"version": "0.1.2",
"version": "0.1.3",
"description": "图片懒加载",

@@ -5,0 +5,0 @@ "main": "src/adapter.js",

@@ -21,3 +21,2 @@ /*

function extendStrict(main, sub) {

@@ -33,3 +32,3 @@ var ret = {};

function applySrc(item, processedSrc) {
function applySrc(item, processedSrc, placeholderSrc) {
if (!processedSrc) {

@@ -40,4 +39,15 @@ return;

item.setAttribute('src', processedSrc);
if (!placeholderSrc) {
return
}
item.onerror = function () {
this.onerror = null;
this.src = placeholderSrc
}
} else {
item.style.backgroundImage = 'url("' + processedSrc + '")';
var bgStr = 'url("' + processedSrc + '")';
if (placeholderSrc) {
bgStr += ',url("' + placeholderSrc + '")';
}
item.style.backgroundImage = bgStr;
}

@@ -54,3 +64,3 @@ }

var item = this;
applySrc(item, item.getAttribute('i-lazy-src'));
applySrc(item, item.getAttribute('i-lazy-src'), item.dataset.placeholder);
item.removeAttribute('i-lazy-src');

@@ -61,3 +71,2 @@ }

adapter.logConfig = function () {

@@ -67,3 +76,2 @@ console.log('lib-img Config\n', config);

adapter.fire = function () {

@@ -80,3 +88,3 @@

if (item.dataset.lazy == 'false' && item.dataset.lazy != 'true') {
applySrc(item, processSrc(item, item.getAttribute(config.dataSrc)));
applySrc(item, item.getAttribute(config.dataSrc), item.dataset.placeholder);
} else {

@@ -93,8 +101,4 @@ item.classList.add(label);

adapter.defaultSrc = 'data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==';
lib.img = adapter;

@@ -101,0 +105,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc