Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

script_list.splice.call(script_list,splice_args); #38

Closed
dexbol opened this issue Aug 2, 2011 · 9 comments
Closed

script_list.splice.call(script_list,splice_args); #38

dexbol opened this issue Aug 2, 2011 · 9 comments
Assignees
Labels

Comments

@dexbol
Copy link

dexbol commented Aug 2, 2011

there are two questions.

what difference between script_list.splice.call(script_list,splice_args) and script_list.splice(splice_args)?

$LAB.script(['test1.php',['test2.php','test3.php']]);

it's just load test1.php , if this statement is wrong ,why do that check the parameter is a array? line 386

@dexbol dexbol closed this as completed Aug 2, 2011
@dexbol dexbol reopened this Aug 2, 2011
@getify
Copy link
Owner

getify commented Aug 2, 2011

I think you're right, the splice call is needlessly verbose as written. it should just be script_list.splice(splice_args).

I'm not sure I understand your second question. $LAB.script("test1.php", ["test2.php", "test3.php"]) should in fact load all 3 scripts. Are you seeing it not do so?

@ghost ghost assigned getify Aug 2, 2011
@dexbol
Copy link
Author

dexbol commented Aug 3, 2011

$LAB.script(['test1.php',['test2.php','test3.php']]);

it just has one parameter ['test1.php',['test2.php','test3.php']] ,not two parameters "test1.php" and ["test2.php", "test3.php"]

@getify
Copy link
Owner

getify commented Aug 3, 2011

I'm sorry, I still don't understand your question. In your example, is it loading all 3 scripts or not?

@dexbol
Copy link
Author

dexbol commented Aug 3, 2011

... I try it again , that may be my mistake

@dexbol dexbol closed this as completed Aug 3, 2011
@dexbol dexbol reopened this Aug 3, 2011
@dexbol
Copy link
Author

dexbol commented Aug 3, 2011

I push the example to internet .http://dexbol.sinaapp.com/labjs/

@getify
Copy link
Owner

getify commented Aug 3, 2011

OK, I see and can reproduce the problem... very strange. But thank you for the bug report. I'll get on fixing it.

@getify
Copy link
Owner

getify commented Aug 3, 2011

OK, I figured out what the bug was, and have fixed it (will come out in 2.0.2 when I get that release out, asap). Those few lines now read (including comments to explain what the heck I was doing!):

if (is_array(script_obj)) {
   // set up an array of arguments to pass to splice()
   splice_args = [].slice.call(script_obj); // first include the actual array elements we want to splice in
   splice_args.unshift(j,1); // next, put the `index` and `howMany` parameters onto the beginning of the splice-arguments array
   script_list.splice.apply(script_list,splice_args); // use the splice-arguments array as arguments for splice()
   j--; // adjust `j` to account for the loop's subsequent `j++`, so that the next loop iteration uses the same `j` index value
   continue;
}

Thanks again for helping find this bug!

@dexbol
Copy link
Author

dexbol commented Aug 3, 2011

OK,thanks for your code and explain too.

@dexbol dexbol closed this as completed Aug 3, 2011
@getify getify reopened this Aug 9, 2011
@getify
Copy link
Owner

getify commented Aug 16, 2011

fixed in v2.0.2

@getify getify closed this as completed Aug 16, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants