作家
登录

JavaScript的API设计原则

作者: 来源: 2017-06-19 17:57:51 阅读 我要评论

) { 
  •  
  •     selector = selector.trim() 
  •  
  •     // If it's a html fragment, create nodes from it 
  •  
  •     // Note: In both Chrome 21 and Firefox 15, DOM error 12 
  •  
  •     // is thrown if the fragment doesn't begin with < 
  •  
  •     if (selector[0] == '<' && fragmentRE.test(selector)) 
  •  
  •       dom = zepto.fragment(selector, RegExp.$1, context), selector = null 
  •  
  •     // If there's a context, create a collection on that context firstand select 
  •  
  •     // nodes from there 
  •  
  •     else if (context !== undefined) return $(context).find(selector) 
  •  
  •     // If it's a CSS selector, use it to select nodes. 
  •  
  •     else dom = zepto.qsa(document, selector) 
  •  
  •   } 
  •  
  •   // If a function is given, call it when the DOM is ready 
  •  
  •   else if (isFunction(selector)) return $(document).ready(selector) 
  •  
  •   // If a Zepto collection is given, just return it 
  •  
  •   else if (zepto.isZ(selector)) return selector 
  •  
  •   else { 
  •  
  •     // normalize array if an array of nodes is given 
  •  
  •     if (isArray(selector)) dom = compact(selector) 
  •  
  •     // Wrap DOM nodes. 
  •  
  •     else if (isObject(selector)) 

  •   推荐阅读

      智慧城市发展路径应分级分类

    智能泊车、长途智能抄表、智能路灯杆、智能井盖&hellip;&hellip;聪明城市扶植正在为我们的生活带来各类便利。聪明城市也成为当前热议的话题。6月8日,第二十届中国北京国际科技家当博览会同>>>详细阅读


    本文标题:JavaScript的API设计原则

    地址:http://www.17bianji.com/lsqh/35828.html

  • 关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)