天天看点

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做了一个处理。

继续阅读