New issue
Advanced search Search tips

Issue 884479 link

Starred by 3 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Sep 17
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

addEventListener Error "Uncaught TypeError: createElement.addEventListener is not a function" in "for in" loop

Reported by l...@unitgreen.com, Sep 15

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36

Steps to reproduce the problem:
1. document.getElementsByClassName("create_page") // <span class="create_page"></span>
2. for(let index in createBtnElements)
3. createBtnElements[index].addEventListener("click",function (element) {console.log(element);});

What is the expected behavior?

What went wrong?
the error message:

"creator.js:84 Uncaught TypeError: createElement.addEventListener is not a function"

but if i click on the element it works. So I don't think this error message is usefull?

Did this work before? N/A 

Chrome version: 68.0.3440.106  Channel: n/a
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
 
Labels: Needs-Triage-M68
Status: WontFix (was: Unconfirmed)
You are iterating over the properties of the collection by using the "in" attribute....
Try iterating only over the indexed items. Change your for loop to be something like:

for (index = 0; index < a.length; ++index) {
    createBtnElements[index]...
}

See: https://stackoverflow.com/questions/22754315/for-loop-for-htmlcollection-elements
I'm sorry and much thank you.
My fault.

Sorry Lukas

Sign in to add a comment