一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

dess中一個簡單的多路委托的實現

復制代碼 代碼如下:
var SDelegate = function(f, b, c) {
if (b) {
this.asFunction_ = function() {
return f.apply(b, arguments);
}
} else {
this.asFunction_ = function() {
return f.apply(this, arguments);
}
}
this.method_ = f;
this.binding_ = b;
this.continus = c;
}
SDelegate.composite = function(d) {
if (d.continus) {
var con = d.continus.composited_ = SDelegate.composite(d.continus);
var method = d.asFunction_;
return function() {
con.apply(this, arguments);
return method.apply(this, arguments);
}
} else {
return d.asFunction_;
}
}
SDelegate.prototype.call = function() {
if (!this.composited_) this.composited_ = SDelegate.composite(this);
return this.composited_.apply(arguments[0], Array.prototype.slice.call(arguments, 1));
}
SDelegate.prototype.remove = function() {
var removeP = function(parent, item, test, data) {
if (!item) return;
parent.composited_ = item.composited_ = null;
if (test(item, data)) {
parent.continus = item.continus;
removeP(parent, item.continus, test, data);
} else {
removeP(item, item.continus, test, data);
}
};
return function(test, data) {
var p = this;
if (test(this, data)) {
p = this.continus;
}
removeP(p, p.continus, test, data);
p.composited_ = null;
return p;
}
}();
SDelegate.prototype.append = function(f, b) {
return new SDelegate(f, b, this);
}

這個SDelegate用起來可能會比較詭異,比如很多操作都要重新賦值。Dess中,SDelegate主要用于一些特定場合,如DOM事件派發。

JavaScript技術dess中一個簡單的多路委托的實現,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 日本高清一区二区三区不卡免费 | 久久国产精品-国产精品 | 91网视频在线观看 | 午夜一级 | 一区二区三区亚洲视频 | 91精品成人 | 免费看岛国视频在线观看 | 国产大臿蕉香蕉大视频女 | 激情小说网站 | 日韩欧美一二三区 | www.欧美com| 亚洲精品综合久久 | 热久久综合网 | 黄网址在线观看 | 在线视频www| 欧美三级视频在线观看 | 热综合一本伊人久久精品 | 国产成人精品一区二三区 | 狠狠干天天爱 | 狠狠久久久久综合网 | 中文国产成人精品少久久 | 国产91一区二区在线播放不卡 | 人人做人人爽人人爱秋霞影视 | 黄色片网站免费在线观看 | 亚洲人的天堂男人爽爽爽 | 国产精品视频国产永久视频 | 玖玖香蕉视频 | 激情五月婷婷综合 | 国产高清精品自在久久 | 久久久国产精品va麻豆 | 91精品国产自产91精品 | 午夜激情在线视频 | 天天操天天干天天插 | 2021成人国产精品 | 欧洲综合色 | 四虎最新紧急入口 | 亚洲综合色视频 | 4hu四虎永久地址 | 国产在线视频99 | 91视频亚洲 | 国产精品视频一 |