IE8 splice issue

Jan 28, 2014 at 3:55 PM
Edited Jan 28, 2014 at 3:59 PM
I'm getting extremely strange behaviour when running in IE8. In one case:
//this.startIndex = 10 
QueryToken.prototype.And = function () {
            this.builder.tree.splice(this.startIndex, 0, { Element: "Start", Name: "And" }); <---------
            return new FieldExpression(this.builder);
From what I understand, this line simply inserts one element into the tree, but in IE8
this.builder.tree goes from having 44 items to 55!

I understand there's not enough information here to recreate and properly investigate the issue, but hopefully enough for someone to recognise what the issue is.

By the way, I had to work around by rewriting the functionality as follows:
Array.prototype.insert = function(){
            var arr = this;
            var startIndex = arguments[0];
            var arr2 = arr.slice(0, startIndex);
            var new_arr =, 1);
            arr2 = arr2.concat(new_arr);
            return arr2.concat(arr.slice(startIndex));

this.builder.tree = this.builder.tree.insert(this.startIndex, { Element: "Start", Name: "And" });
Jan 28, 2014 at 9:02 PM
Hi Bryon,

Thanks for reporting this and for posting the workaround!

There are some problems with splice in IE8 and below, indeed. I can see Google showing a lot of matches on "IE8 splice". I'll try to include the fix in the next versions of the CamlJs.