PDA

View Full Version : [OPEN] [ExtJS 4.0.7, Chrome 30.0.1599.69]Ext.view.View fails to render (Ext.XTemplate fails)



wojteks27
10 Oct 2013, 3:30 AM
EDIT : It's a bug. It is caused by ECMAScript 6 support (Array.prototype has function values)

If you call f([1,2,3], obj) in an ECMAScript 5 environment, then the values reference inside the with statement will resolve to obj. However, ECMAScript 6 introduces a values property on Array.prototype (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype) (so that it will be available on every array). So, in a JavaScript environment that supports ECMAScript 6, the values reference inside the with statement will resolve to [1,2,3].values.

Due to https://code.google.com/p/chromium/issues/detail?id=306019,
in Ext.XTemplate, compileTpl function there is:


tpl.compiled = function(values, parent, xindex, xcount) {
var vs,
length,
buffer,
i;


if (tpl.test && !tpl.test.call(me, values, parent, xindex, xcount)) {
return '';
}
//HERE IF values IS AN ARRAY, vs EQUALS function values() { [native code] } INSTEAD OF AN ARRAY OF OBJECTS
vs = tpl.target ? tpl.target.call(me, values, parent) : values;
console.debug(vs);

if (!vs) {
return '';
}


parent = tpl.target ? values : parent;
if (tpl.target && Ext.isArray(vs)) {
buffer = [];
length = vs.length;
if (tpl.exec) {
for (i = 0; i < length; i++) {
buffer[buffer.length] = evaluatedFn.call(me, vs[i], parent, i + 1, length);
tpl.exec.call(me, vs[i], parent, i + 1, length);
}
} else {
for (i = 0; i < length; i++) {
buffer[buffer.length] = evaluatedFn.call(me, vs[i], parent, i + 1, length);
}
}
return buffer.join('');
}


if (tpl.exec) {
tpl.exec.call(me, vs, parent, xindex, xcount);
}


return evaluatedFn.call(me, vs, parent, xindex, xcount);
};


return this;
},


The function that fails (tpl.target)

function anonymous(values,parent
/**/) {
var Ext=window.ExtBox1;try{with(values){ return values;}}catch(e){return;}
}

It might save someone 3h of debugging I just did.

Regards,
Wojtek

wojteks27
10 Oct 2013, 3:51 AM
Can someone please move it to bugs section?

Thanks

Gary Schlosberg
11 Oct 2013, 5:02 AM
Thanks for the report. I moved this thread to the Bugs forum as requested, and hope as well that it might save someone the time you spent. As far as filing a bug, the code segment you referenced is not in the next version of the code (4.1.0) let alone the current one, and Chrome 30 didn't exist when 4.0.7 released in 2011. If you feel this is still an issue in the current release, please submit a test case and we'll get it fixed. Thanks.

wojteks27
11 Oct 2013, 5:10 AM
Yes, of course you are right. Just wanted to help anybody who'd be looking for such unexpected problem.

dongryphon
11 Oct 2013, 9:50 PM
Thanks for the report! I have opened a bug in our bug tracker.