争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

zepto是什么

时间:2024/4/29作者:未知来源:争怎路由网人气:

$)')) } //给需要的样式值后面加上'px'单位,除了cssNumber里面的指定的那些 function maybeAddPx(name, value) { return (typeof value == "number" && !cssNumber[dasherize(name)]) ? value + "px" : value } //获取节点的默认display属性 function defaultDisplay(nodeName) { var element, display if (!elementDisplay[nodeName]) { //缓存里不存在 element = document.createElement(nodeName) document.body.appendChild(element) display = getComputedStyle(element, '').getPropertyValue("display") element.parentNode.removeChild(element) display == "none" && (display = "block") //当display等于none时,设置其值为block,搞不懂为毛要这样 elementDisplay[nodeName] = display //缓存元素的默认display属性 } return elementDisplay[nodeName] } //获取指定元素的子节点(不包含文本节点),Firefox不支持children,所以只能通过筛选childNodes function children(element) { return 'children' in element ? slice.call(element.children) : $.map(element.childNodes, function(node) { if (node.nodeType == 1) return node }) } // `$.zepto.fragment` takes a html string and an optional tag name // to generate DOM nodes nodes from the given html string. // The generated DOM nodes are returned as an array. // This function can be overriden in plugins for example to make // it compatible with browsers that don't support the DOM fully. zepto.fragment = function(html, name, properties) { //将类似<div class="test"/>替换成<div class="test"></div>,算是一种修复吧 if (html.replace) html = html.replace(tagExpanderRE, "<$1></$2>") //给name取标签名 if (name === undefined) name = fragmentRE.test(html) && RegExp.$1 //设置容器标签名,如果不是tr,tbody,thead,tfoot,td,th,则容器标签名为div if (!(name in containers)) name = '*' var nodes, dom, container = containers[name] //创建容器 container.innerHTML = '' + html //将html代码片断放入容器 //取容器的子节点,这样就直接把字符串转成DOM节点了 dom = $.each(slice.call(container.childNodes), function() { container.removeChild(this) //逐个删除 }) //如果properties是对象, 则将其当作属性来给添加进来的节点进行设置 if (isPlainObject(properties)) { nodes = $(dom) //将dom转成zepto对象,为了方便下面调用zepto上的方法 //遍历对象,设置属性 $.each(properties, function(key, value) { //如果设置的是'val', 'css', 'html', 'text', 'data', 'width', 'height', 'offset',则调用zepto上相对应的方法 if (methodAttributes.indexOf(key) > -1) nodes[key](value) else nodes.attr(key, value) }) } //返回将字符串转成的DOM节点后的数组,比如'<li></li><li></li><li></li>'转成[li,li,li] return dom } // `$.zepto.Z` swaps out the prototype of the given `dom` array // of nodes with `$.fn` and thus supplying all the Zepto functions // to the array. Note that `__proto__` is not supported on Internet // Explorer. This method can be overriden in plugins. zepto.Z = function(dom, selector) { dom = dom

关键词:zepto是啥




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版