From beb015cb5adb6716a1b18a921a893f86f774b719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Wed, 26 Jun 2013 00:20:53 +0900 Subject: [PATCH] remove unless indexOf function need to rebuild --- src/sticky.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/sticky.js b/src/sticky.js index f779dea..2570275 100644 --- a/src/sticky.js +++ b/src/sticky.js @@ -163,11 +163,12 @@ define(function (require, exports, module) { this.callback.call(this, false); }; - // 需要占位符的情况有: 1) position: static or relative; 但除了 display 不是 block + // 需要占位符的情况有: 1) position: static or relative,除了 display 不是 block 的情况 Sticky.prototype._addPlaceholder = function() { var need = false; + var position = this.elem.css("position"); - if (indexOf(["static", "relative"], this.elem.css("position")) !== -1) { + if (position === 'static' || position === 'relative') { need = true; } if (this.elem.css("display") !== "block") { @@ -256,13 +257,4 @@ define(function (require, exports, module) { } } - function indexOf(array, item) { - if (array == null) return -1; - var nativeIndexOf = Array.prototype.indexOf; - - if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item); - for (var i = 0; i < array.length; i++) if (array[i] === item) return i; - return -1; - } - });