dkern / jquery.lazy

A lightweight, fast, feature-rich, powerful and highly configurable delayed content, image and background lazy loading plugin for jQuery & Zepto.
http://jquery.eisbehr.de/lazy
Other
1.02k stars 236 forks source link

JS Error When Using on Cloned Template #259

Closed simonferndriger closed 1 year ago

simonferndriger commented 2 years ago

When using $e = $('template').contents().clone() as an element and appending it with $('body').append($e), calling $e.Lazy() afterwards triggers a JS error "Cannot call .toLowerCase() of undefined".

dkern commented 2 years ago

Isn't a cloned element in jQuery a virtual Element? So don't you need to select the element after appending it to get the correct instance?

$e = $('template').contents().clone();
$('body').append($e);
$('clonedTemplateSelector').Lazy();
simonferndriger commented 2 years ago

That could be, however, with jQuery I can perform all regular acitons on that virtual element, so I don't see any reason why this should not be the case here... I could save an additional select and thereby improve performance.

dkern commented 1 year ago

I close this, more of an edge case and I will not invest into it actually.