Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot pass a node list or an array of html elements to the constructor #159

Open
ThisNameWasTaken opened this issue Mar 29, 2019 · 0 comments

Comments

@ThisNameWasTaken
Copy link

Steps to reproduce the problem

Inside a js file write the fallowing code

new Rellax(document.querySelectorAll('.rellax'));

Current behavior

This error is thrown

- TypeError: el.getAttribute is not a function

Expected behavior

It should work just like

new Rellax('.rellax');

Motivation

The first scenario can be useful when you already stored a node list and need to share it with other components as well. On large DOM trees this could increase performance since there would be no need to query multiple times for the same elements.

For instance

const elements = document.querySelectorAll('.rellax');
new Rellax(elements);
new SomeOtherComponent(elements);
// Do more work on the elements ...

I will make a PR which enables this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant