四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

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中一個簡單的多路委托的實現,轉載需保留來源!

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

主站蜘蛛池模板: 和平视频| 四大名捕 电影| 情哥哥| 一二三年级的童话绘画| 斓曦个人简介| 秀人网美女屋| 女人的战争剧情介绍| 四年级竖式1000道题免费打印| 《两个女人》韩国电影简介| 陈建斌电影| 买下我完整版电影免费观看| 侠侣探案| 囚徒 电影| 鬼整人| 小数除法竖式50道带答案| 国产精品欧美大片| 第一财经今日股市直播间在线直播| 掐脖子的视频| 大树君| 徐方| 被抛弃的青春1982| 经济合同法| 卧虎在线观看| 头文字d里演员表| 我说你做| 骑脖子视频| 黄柳霜| 孽债电视剧演员表| 甜蜜宝贝电影| 繁星诗集1~25篇| 伪装者 豆瓣| 我的新学校英语作文| 电影继父| 情人电视剧| 我的快乐歌词| 黄明昊身高| 恐怖地带| 违规吃喝研讨发言材料| 肱骨骨折能评几级伤残| 腰带之下| 王卓淇|