Skip to content

Commit

Permalink
Extend elements_selector option to also support element and not only …
Browse files Browse the repository at this point in the history
…string (verlok#130)
  • Loading branch information
SassNinja authored and verlok committed Sep 13, 2017
1 parent 197e72f commit 9e9ef6b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion dist/lazyload.es2015.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ LazyLoad.prototype = {

update: function () {
const settings = this._settings;
const elements = settings.container.querySelectorAll(settings.elements_selector);
const elements = typeof settings.elements_selector === "object"
? settings.elements_selector
: settings.container.querySelectorAll(settings.elements_selector);

this._elements = purgeElements(Array.prototype.slice.call(elements)); // nodeset to array for IE compatibility
if (this._observer) {
Expand Down
2 changes: 1 addition & 1 deletion dist/lazyload.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var _this2 = this;

var settings = this._settings;
var elements = settings.container.querySelectorAll(settings.elements_selector);
var elements = _typeof(settings.elements_selector) === "object" ? settings.elements_selector : settings.container.querySelectorAll(settings.elements_selector);

this._elements = purgeElements(Array.prototype.slice.call(elements)); // nodeset to array for IE compatibility
if (this._observer) {
Expand Down
2 changes: 1 addition & 1 deletion dist/lazyload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vanilla-lazyload",
"version": "10.0.1",
"version": "10.0.2",
"description": "A fast, lightweight script to load images as they enter the viewport. SEO friendly, it supports responsive images (both srcset + sizes and picture) and progressive JPEG",
"main": "dist/lazyload.min.js",
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion src/lazyload.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ LazyLoad.prototype = {

update: function () {
const settings = this._settings;
const elements = settings.container.querySelectorAll(settings.elements_selector);
const elements = typeof settings.elements_selector === "object"
? settings.elements_selector
: settings.container.querySelectorAll(settings.elements_selector);

this._elements = purgeElements(Array.prototype.slice.call(elements)); // nodeset to array for IE compatibility
if (this._observer) {
Expand Down
2 changes: 1 addition & 1 deletion typings/lazyload.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interface ILazyLoadOptions {
threshold?: number;
container?: HTMLElement;
elements_selector?: string;
elements_selector?: any;
throttle?: number;
data_src?: string;
data_srcset?: string;
Expand Down

0 comments on commit 9e9ef6b

Please sign in to comment.