zotero / scaffold

Zotero translator creation IDE
http://www.zotero.org/support/dev/scaffold
38 stars 9 forks source link

Testing in Scaffold not working #26

Closed zuphilip closed 8 years ago

zuphilip commented 8 years ago

It seems for me that running any tests in scaffold is not working. @adam3smith @aurimasv Can you still run tests in scaffold or can you reproduce the error?

My browser console shows the error:

TypeError: items[i].getElementsByTagName is not a function scaffold.js:928:4
adam3smith commented 8 years ago

same problem. I can create but not run.

zuphilip commented 8 years ago

Okay, I debbuged the problem further. It looks that first the loop variable i equals 0 which is okay and then the variable equals append (function name) and the error happens:

scaffold-error

I guess we have to rewrite the for-loop here... Would you agree that it should be simply be

for (var i=0; i<items.length; i++) {

?

aurimasv commented 8 years ago

Yes, but where is the "append"coming from? Sounds like something is modifying the array prototype, which is ok, I guess, but that shouldn't be our code. On Apr 3, 2016 13:24, "Philipp Zumstein" notifications@github.com wrote:

Okay, I debbuged the problem further. It looks that first the loop variable i equals 0 which is okay and then the variable equals append (function name) and the error happens:

[image: scaffold-error] https://cloud.githubusercontent.com/assets/5199995/14233704/4c1bc4c2-f9d0-11e5-85d1-023955de849a.jpg

I guess we have to rewrite the for-loop here... Would you agree that it should be simply be

for (var i=0; i<items.length; i++) {

?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/zotero/scaffold/issues/26#issuecomment-205015279

zuphilip commented 8 years ago

I just tested that loop separately: for (j in items) { Zotero.debug(j); } gives

(3)(+0006464): 0
(3)(+0000000): append
(3)(+0000000): remove
(3)(+0000000): item
(3)(+0000000): length

Thus, it seems that these are the functions/methods of (the object) items. No?

zuphilip commented 8 years ago

@aurimasv items is a ChromeNodeList and not an array. Does this make sense?

zuphilip commented 8 years ago

Hm.. the for loops seem to work now in https://github.com/zuphilip/scaffold/commit/e8052b194bb0d25567ee901e9ba5b12ca1a1bcd0, but there is another error when trying to update a test:

TypeError: listbox.selectedItems.slice is not a function

My impression is that selectedItems changed its type to ChromeNodeList.

Update: Yes, indeed this happend in Firefox 45, see https://hg.mozilla.org/releases/mozilla-b2g44_v2_5/rev/fb998e8c0b94

zuphilip commented 8 years ago

Okay, I think I fixed it.

dstillman commented 8 years ago

Changed in https://bugzilla.mozilla.org/show_bug.cgi?id=120684, BTW

(Along with [...listbox.selectedItems], Array.from(listbox.selectedItems) also works for this sort of thing.)