Closed GoogleCodeExporter closed 9 years ago
I haven't looked closely yet, but I wanted to let you know I do see this report
and will be investigating soon.
Original comment by gden...@google.com
on 12 Feb 2013 at 2:19
Thanks for your quick response!
Please let me know if you need any additional information.
Original comment by michael....@gmail.com
on 17 Feb 2013 at 10:17
I think there may be something wrong with your attached code. Take this snippet
of code from otherScript.js:
1 function _each(iterator, context) {
2 for (var i = 0, length = this.length >>> 0; i < length; i++) {
3 if (i in this) iterator.call(context, this[i], i, this);
4 }
5 }
6 arrayProto.filter = MyEnumerable.filter;
7 arrayProto._each = MyEnumerable._each;
The definition of _each on line (1) appears to be unused, and
MyEnumerable._each is never assigned, so line (7) appears to have no effect.
Original comment by gden...@google.com
on 19 Feb 2013 at 7:20
You are right, however the problem still remains even if you remove the _each
method.
I investigated further our scenario and it seems to happen when ever
prototype.js of version 1.7 is used (the was a bug there that caused this
problem and they fixed it in 1.7.1).
I only now noticed that it is possible to compile the sources with the
goog.NATIVE_ARRAY_PROTOTYPES flag set to "false" which will force the library
not to use the Array.prototype functions.
Thank you for your time and I apologize for the taking up yours.
Original comment by michael....@gmail.com
on 21 Feb 2013 at 5:46
For your test case, wgxpath will call goog.array.filter when the document mode
is older than that of IE9. In the presence of Array.proto.filter(),
goog.array.filter calls the that particular filter function. In this case, the
function resolves to the user-implemented one in otherScript.js.
function each(iterator, context) {
var index = 0;
this._each(function(value) {
iterator.call(context, value, index++);
});
return this;
}
function filter(iterator, context) {
var results = [];
this.each(function(value, index) {
if (iterator.call(context, value, index))
results.push(value);
});
return results;
}
However, I don't see how calling "this.each()" in filter() should succeed,
given that there's no each() function taking the argument (a function) you are
passing. I am not sure if I was missing something or your implementation has
issue. Could you check that? Thanks.
Original comment by zhoumoto...@gmail.com
on 22 Feb 2013 at 11:00
BTW, if you set goog.NATIVE_ARRAY_PROTOTYPES to "false", goog.array.filter will
instead use the implementation in the Closure library, which avoids calling
your own filter() function.
Original comment by zhoumoto...@gmail.com
on 22 Feb 2013 at 11:03
That's exactly what I want to achieve, I do not want a bad implementation of
the Array functions to have an impact of the way that wgxpath works.
Original comment by michael....@gmail.com
on 24 Feb 2013 at 7:38
Since it was a buggy version of prototype.js adding a bogus method to the Array
prototype, and since it can be fixed by upgrading to a newer version of
prototype.js, I'm closing the bug.
Original comment by gden...@google.com
on 25 Feb 2013 at 2:22
Original issue reported on code.google.com by
michael....@gmail.com
on 11 Feb 2013 at 10:58Attachments: