From 7932d986e8a8c6154a636b4fea588bdbf93a9077 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 14 Jan 2016 21:49:07 +0800 Subject: [PATCH] Add documentation to accuse Baidu developer --- cocos2d/core/platform/js.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cocos2d/core/platform/js.js b/cocos2d/core/platform/js.js index 25e6a43fd0..b91df6bbfb 100644 --- a/cocos2d/core/platform/js.js +++ b/cocos2d/core/platform/js.js @@ -630,6 +630,22 @@ js.array = { return arr_clone; }, + /** + * Exact same function as Array.prototype.indexOf. + * HACK: ugliy hack for Baidu mobile browser compatibility, + * stupid Baidu guys modify Array.prototype.indexOf for all pages loaded, + * their version changes strict comparison to non-strict comparison, + * it also ignores the second parameter of the original API, + * and this will cause event handler enter infinite loop. + * Baidu developers, if you ever see this documentation, + * here is the standard: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf + * Seriously ! + * + * @method indexOf + * @param {any} searchElement Element to locate in the array. + * @param {Number} [fromIndex=0] The index to start the search at + * @return {Number} returns the first index at which a given element can be found in the array, or -1 if it is not present. + */ indexOf: Array.prototype.indexOf, };