2014-12-03 65 views
0

檢查小提琴:爲什麼v1.3.0中的角度去抖動被破壞?

http://jsfiddle.net/9sqtvcou/1/

類型的東西輸入,然後等待500毫秒。如果您將「外部資源」更改爲版本1.2.27(自發布此日期以來的最新版本v1.2),它將起作用,否則不起作用。

這是潛在的相關代碼:

var debounceDuration = $parse($attrs.debounce)($scope); 
var immediate = !!$parse($attrs.immediate)($scope); 
var debouncedValue, pass; 
var prevRender = ngModelController.$render.bind(ngModelController); 
var commitSoon = debounce(function (viewValue) { 
    pass = true; 
    ngModelController.$setViewValue(viewValue); 
    pass = false; 
}, parseInt(debounceDuration, 10), immediate); 
ngModelController.$render = function() { 
    prevRender(); 
    commitSoon.cancel(); 
    //we must be first parser for this to work properly, 
    //so we have priority 999 so that we unshift into parsers last 
    debouncedValue = this.$viewValue; 
}; 
ngModelController.$parsers.unshift(function (value) { 
    if (pass) { 
    debouncedValue = value; 
    return value; 
    } else { 
    commitSoon(ngModelController.$viewValue); 
    return debouncedValue; 
    } 
}); 

我不熟悉的角度,所以我想知道:什麼事是打破了V1.3的角度去抖?

編輯: 技術細節的答案會優先於抽象的答案。

回答