色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

dess中一個(gè)簡單的多路委托的實(shí)現(xiàn)

復(fù)制代碼 代碼如下:
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);
}

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

JavaScript技術(shù)dess中一個(gè)簡單的多路委托的實(shí)現(xiàn),轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 岱山县| 乌鲁木齐县| 蒙自县| 云龙县| 且末县| 金湖县| 沅陵县| 南皮县| 敦化市| 禹州市| 汤原县| 广州市| 新化县| 无极县| 兴海县| 靖安县| 女性| 无极县| 乌兰察布市| 盘山县| 周至县| 牙克石市| 焉耆| 临颍县| 疏附县| 安康市| 崇礼县| 甘德县| 盐山县| 滦平县| 夹江县| 墨竹工卡县| 双柏县| 太康县| 高碑店市| 伊宁市| 黄骅市| 乌拉特后旗| 开远市| 武功县| 根河市|