diff --git a/avalon.observe.js b/avalon.observe.js index ea46ba84a..5bc211d88 100644 --- a/avalon.observe.js +++ b/avalon.observe.js @@ -1471,19 +1471,33 @@ .replace(rnumber, ",") .replace(rcommaOfFirstOrLast, "") .split(rcommaInMiddle) - return cacheVars(key, uinqSet(vars)) + return cacheVars(key, uniqSet(vars)) } - function uinqSet(arr) { - var set = new Set - arr.forEach(function(el) { - set.add(el) - }) - var ret = [] - set.forEach(function(el) { - ret.push(el) - }) + + function uniqSet(array) { + var ret = [], unique = {} + for (var i = 0; i < array.length; i++) { + var el = array[i] + var id = el && typeof el.$id === "string" ? el.$id : el + if (!unique[id]) { + unique[id] = ret.push(el) + } + } return ret } + + void function() { + var test = [1, 2, 3, 1] + if (typeof Set == "function" && (new Set(test)).size == 3) { + var uniqSet = function(arr) {//重写uniqSet + var set = new Set(arr), ret = [] + set.forEach(function(el) { + ret.push(el) + }) + return ret + } + } + }() function addDeps(scope, prop, data) { var obj = scope.$accessors @@ -2491,7 +2505,7 @@ } catch (e) { launch = avalon.tick } - + duplexBinding.SELECT = function(element, evaluator, data) { var $elem = avalon(element) function updateVModel() { diff --git a/iscroll.js b/iscroll.js index 5f9fb7a4d..f8b62d9d7 100644 --- a/iscroll.js +++ b/iscroll.js @@ -1,7 +1,7 @@ function IScroll (el, options) { this.wrapper = typeof el == 'string' ? document.querySelector(el) : el; this.scroller = this.wrapper.children[0]; - this.scrollerStyle = this.scroller.style; // cache style for better performance + this.scrollerStyle = this.scroller.style; //保存滚动条元素的样式对象,以提高性能 this.options = { @@ -76,16 +76,12 @@ IScroll.prototype = { version: '/* VERSION */', _init: function () { - this._initEvents(); - -// INSERT POINT: _init - + this._initEvents();//绑定事件 }, destroy: function () { - this._initEvents(true); - - this._execEvent('destroy'); + this._initEvents(true);//移除事件 + this._execEvent('destroy');//执行用户回调 }, _transitionEnd: function (e) { @@ -96,7 +92,7 @@ IScroll.prototype = { this._transitionTime(); if ( !this.resetPosition(this.options.bounceTime) ) { this.isInTransition = false; - this._execEvent('scrollEnd'); + this._execEvent('scrollEnd');//执行用户回调 } }, @@ -127,14 +123,14 @@ IScroll.prototype = { this.directionY = 0; this.directionLocked = 0; - this._transitionTime(); + this._transitionTime();//设置CSS3 渐变时长 transition-duration this.startTime = utils.getTime(); if ( this.options.useTransition && this.isInTransition ) { this.isInTransition = false; pos = this.getComputedPosition(); - this._translate(Math.round(pos.x), Math.round(pos.y)); + this._translate(Math.round(pos.x), Math.round(pos.y));//强制回到起始位置 this._execEvent('scrollEnd'); } else if ( !this.options.useTransition && this.isAnimating ) { this.isAnimating = false; @@ -234,7 +230,7 @@ IScroll.prototype = { this.moved = true; - this._translate(newX, newY); + this._translate(newX, newY);//移动到新位置 /* REPLACE START: _move */ diff --git a/test1.html b/test1.html index 089f8400f..85f3649a2 100644 --- a/test1.html +++ b/test1.html @@ -23,42 +23,20 @@ }) window.onload = function() { - var elem = document.querySelector("#son") - var offset = function(el) { - var left = -el.offsetLeft, - top = -el.offsetTop; - - // jshint -W084 - while (el = el.offsetParent) { - left -= el.offsetLeft; - top -= el.offsetTop; - } - // jshint +W084 - - return { - left: left, - top: top - }; - }; - - elem.addEventListener("DOMNodeRemovedFromDocument", function() { - setTimeout(function() { - console.log(document.documentElement.contains(elem)) - console.log("ddd") - },4) - - }) + // var elem = document.querySelector("#son") + + setTimeout(function() { // elem.value = "dddddddddddddddd" }, 3000) setTimeout(function() { - var el = document.querySelector("#parent") - el.parentNode.removeChild(el) + // var el = document.querySelector("#parent") + // el.parentNode.removeChild(el) }, 3000) } - + @@ -84,8 +62,8 @@ Female - + +

sss