jqm源码之propExists

jqm源码系列之propExists

 

//创建的一个body的jQuery对象
var fakeBody  = $("<body>").prependTo("html"),
      //body的style对象
      fbCSS = fakeBody[0].style,
      vendors = ["Webkit","Moz","O"];


/*
 * @name propExists
 * @param prop
 * @info 判断给定的参数是否支持,其实比较的是body对象的style对象是否含有
*/
function propExists(prop){
      //假设prop为boxShadow,uc_prop就为BoxShadow
      var uc_prop = prop.charAt(0).toUpperCase() + prop.substr(1),
           
            //vendors.join(uc_prop + " ")  返回的是"WebkitBoxShadow MozBoxShadow O"
            //props为["boxShadow","WebkitBoxShadow","MozBoxShadow","OBoxShadow","BoxShadow"]
            props = (prop + " " + vendors.join(uc_prop + " ") + uc_prop).split("");
       //v从0开始,props是一个长度为4的数组 
       for(var v in props){
           //有就返回true
            if(fbCSS[props[v]] !== undefined){
                    return true;
            }
       }
}

 

 

你可能感兴趣的:(JQM,propExists)