Module query selector return NodeList
geraldnako opened this issue · 1 comments
Hi, recently I was testing the Locomotive Boilerplate and I found out this tiny amazing framework. Really great job.
I am facing an issue with the module query selector. In the modal example this.$('accept').style.display = 'none';
is giving an error since this.$('accept')
returns a NodeList.
I can make this work by using this.$('accept')[0].style.display = 'none';
or by "looping" the NodeList.
Is there any solution that I can directly select an element in the module scope?
Hey, thank you! These are indeed the two solutions. It's by design. We did return the element directly in previous versions but if you add another element with the same name, it will break your code. By looping you are sure it will always work, or the [0]
at least won't throw an error.