天天看點

YUI的mix方法

YUI有一個mix方法:

Applies the supplier's properties to the receiver. By default all prototype and static propertes on the supplier are applied to the corresponding spot on the receiver. By default all properties are applied, and a property that is already on the reciever will not be overwritten. The default behavior can be modified by supplying the appropriate parameters.

這個方法可以使receiver接受supplier的屬性和方法。預設情況下supplier上面的原型和靜态屬性會應用到receriver相應的屬性上面,預設情況所有的屬性都會被接受,receiver上面已有屬性不會被覆寫。

YUI.mix(r,s,ov,wl,mode,merge);

主要的和最常用的參數是r和s兩個

r是receiver

s時supplier

ov是一個對象,辨別要要覆寫的屬性

wl是一個白名單,

mode是覆寫的模式

merge是一個布爾值,标示是否要對屬性對象也做合并

看看裡面的幾種覆寫時如何實作的

ie不會枚舉javascript對象上面的native屬性,即便這個屬性被重寫過。

YUI的_iefix對toString做了一個處理。

繼續閱讀