extjs - JavaScript error in IE8 but not in IE 10 -
i using ie 10 , developed tree panel using extjs 4.1. when run application in ie 10 works fine switch ie 8 (within ie 10 using ie developer toolbar browser mode option), javascript error. have never seen such inconsistent behavior far extjs.
please using following fiddle reproduce issue.
ext.create('ext.tree.panel', { title: 'simple tree', renderto: ext.getbody(), width: 400, height: 400, store: { root: { expanded: true, children: [{ checked: false, text: "1 detention", expanded: true, children: [{ checked: false, text: '1.1 foo', leaf: false, children: [{ checked: false, text: "1.1.1 india", expanded: true }, { checked: false, text: "1.1.2 singapore", expanded: true }, { checked: false, text: "1.1.3 usa", expanded: true }] }, { checked: false, text: '1.2 bar', leaf: true }] }, { checked: false, text: "2 homework", expanded: true, children: [{ checked: false, text: "2.1 book report", leaf: true }, { checked: false, text: "2.2 algebra", expanded: true, children: [{ checked: false, text: "2.2.1 buy lottery tickets", leaf: true }, { checked: false, text: "2.2.2 buy lottery tickets 2", leaf: true }] }, { checked: false, text: "2.3 english report", leaf: true }] }, { checked: false, text: "3 buy lottery tickets", leaf: true }] } }, rootvisible: false, disableselection: true, //selmodel: {mode: 'simple'}, listeners: { checkchange: function (record, checked, opts) { if (!checked) return; var parentnode = record.parentnode; // deselect children function deselectchildren(record) { record.eachchild(function (record) { record.set('checked', false); deselectchildren(record); }); } deselectchildren(record); // see if siblings selected var allsiblingselected = false; if (parentnode) { allsiblingselected = parentnode.childnodes.reduce(function (previous, node) { return previous && node.get('checked'); }, true); } if (allsiblingselected) { parentnode.set('checked', true); // apparently won't fire on own this.fireevent('checkchange', parentnode, true, opts); } // deselect ancestors else { while (parentnode) { parentnode.set('checked', false); parentnode = parentnode.parentnode; } } } } });
i attaching error getting in ie 8
please provide suggestion.
thank you
reduce
isn't supported in old browsers, it's implemented in ecma script 5 check https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/array/reduce
you can define function old browsers :
if ('function' !== typeof array.prototype.reduce) { array.prototype.reduce = function(callback, opt_initialvalue){ 'use strict'; if (null === || 'undefined' === typeof this) { // @ moment modern browsers, support strict mode, have // native implementation of array.prototype.reduce. instance, ie8 // not support strict mode, check useless. throw new typeerror( 'array.prototype.reduce called on null or undefined'); } if ('function' !== typeof callback) { throw new typeerror(callback + ' not function'); } var index = 0, length = this.length >>> 0, value, isvalueset = false; if (1 < arguments.length) { value = opt_initialvalue; isvalueset = true; } ( ; length > index; ++index) { if (!this.hasownproperty(index)) continue; if (isvalueset) { value = callback(value, this[index], index, this); } else { value = this[index]; isvalueset = true; } } if (!isvalueset) { throw new typeerror('reduce of empty array no initial value'); } return value; }; }
Comments
Post a Comment