rgrove / lazyload

:skull: An ancient tiny JS and CSS loader from the days before everyone had written one. Unmaintained.
MIT License
1.39k stars 288 forks source link

Binding context/scope #1

Closed rauanmayemir closed 14 years ago

rauanmayemir commented 14 years ago

I'm using prototype js, binding context doesn't work properly. i'm passing this for obj, but it doesn't work. it's much simpler for me to apply context via bind(this) for callback function, don't it?

rauanmayemir commented 14 years ago

nb: i'm passing this from prototype js Classes (their "methods")

rgrove commented 14 years ago

Can you please post some code that reproduces the problem?

rauanmayemir commented 14 years ago

Hm.. i remember, i really had such problems, but after solving them, i cannot reproduce again.

I guess there was problems with the scope of eval'd scripts came from ajax.

rauanmayemir commented 14 years ago

Take a look at this fragment: if (pending[type] || !(p = pending[type] = queue[type].shift())) { return; }

Case is: i'm lazy loading script from one place, and some time later loading it again, but this string !(p = pending[type] = queue[type].shift()) returns me true.

After firebuging i noticed, that either pending or queue doesn't clean up after loading scripts, so that in next cycle queue or pending is not empty.

I'm using Firefox 3.5.8, but in Chrome 4 results are the same.

rgrove commented 14 years ago

The !(p = pending[type] = queue[type].shift()) check will evaluate to true when the queue is empty, so it sounds like this is working correctly. If items weren't being removed from the queue, that expression would evaluate to false.

Since I haven't seen an issue like the one you describe, I can't debug this unless you can provide executable code that reproduces the problem.

rgrove commented 14 years ago

Can't reproduce and no new info, so closing.