代码拉取完成,页面将自动刷新
兼容 jQuery API 的 DOM / AJAX 基础库,基于原创的 ECMA / W3C polyfill 构建,并内置很多常用的 jQuery 扩展 API。
在 API 形态上尽力兼容 jQuery 的同时,iQuery 在内部实现上采取 “面向未来,向前兼容”的 Polyfill 策略 —— jQuery 标准 API(2500 行)、iQuery 扩展 API(1800 行)尽力基于 W3C、ECMA 最新标准中的优秀 API,老旧浏览器兼容代码(部分基于 jQuery API,1200+ 行)尽力包装成与新 API 相同的形式(原型拓展),并独立为外部模块。这样做不但能复用 jQuery API 来高效实现,还方便开发人员自行裁剪。
【注】对 IE 的兼容仅限其“标准模式”,而非“兼容性视图”。
iQuery | jQuery | Zepto | JSLite | |
---|---|---|---|---|
浏览器兼容 | IE 8+ | IE 6+ (v1.x)、IE 9+ (v2.0+) | IE 10+ | IE 10+ |
ECMA / W3C polyfill | 多 | ×(各模块自行实现 Fix) | 少 | 少 |
扩展 API | 多 | 少 | 少 | |
触控事件 | 单指 | × | 多指 | × |
源代码模块化 | AMD | AMD | IIFE | IIFE |
API 注解(JSDoc) | √ | × | × | × |
测试框架 | Mocha | QUnit | Evidence | Mocha |
基础知识 ——《jQuery API 文档》
HTML 源码基本结构
<!DocType HTML>
<html><head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge, Chrome=1" />
<!-- 1. 独立使用 -->
<script src="path/to/iQuery.min.js"></script>
<!-- 2. AMD 规范加载 -->
<script src="https://cdn.bootcss.com/require.js/2.3.5/require.min.js"></script>
<script>
require.config({
paths: {
iQuery: 'path/to/iQuery.min.js'
}
});
</script>
</head><body>
...
</body></html>
以下扩展已收录在本项目的 jQueryKit.js 中,方便配合其它 jQuery API 实现 ——
【API 文档】及更多变更:
$.every()
、$.wait()
、$.start()
、$.end()
$.unique()
方法不局限于 DOM 元素数组$.trace()
$.patch()
$.byteLength()
$.curry()
$.fileName()
、$.filePath()
、$.urlDomain()
$.paramSign()
$.parseJSON()
支持 递归解析,会将 JSON 字符串中的内层字符串 eval 为 JS 实值/例$.formatJSON()
$.ajaxTransport()
重载 JSONP 实现,支持基本的异常处理$.ajax()
支持 form 元素、FormData 对象的请求数据形式,整合 XHR、XDR、JSONP、iframe 自适应 跨域请求
$.ajax()
自动转换响应内容为 HTML、XML 或 JSON 对象实例$.delete()
、$.put()
,方便实现基于 RESTful API 的单页应用$.fn.htmlExec()
W3C HTML 解析器方法,并基于此重构 $.fn.load()
内部实现,方便 DOM 片段清理、脚本调试$.fn.mediaReady()
$.fn.ajaxSubmit()
(基于前述的几个 AJAX 增强方法 构建)$.isSelector()
img, link[type="image/x-icon"], svg, canvas
及设置了 background-image
的普通元素input[type="submit"], input[type="reset"], input[type="image"]
:indeterminate
,属 CSS 3 标准
:focusable
,属 jQuery UI 标准
:data()
,属 jQuery UI 标准
:field
,匹配所有含 可提交字段的元素:list
,等价于 ul, ol, dl, tbody, datalist
:media
,等价于 :image, iframe, object, embed, audio, video
:loaded
,等价于 img, audio, video
、document
加载结束:scrollable
,匹配所有 内容可滚动的元素$.fn.sameParents()
$.fn.scrollParents()
$.fn.scrollTo()
.attr()
、.prop()
、.css()
、.data()
)均支持“不传键名时返回 信息全集”特性$.fn.reduce()
$.fn.show()
兼容 元素非固有 display 属性值,避免破坏 复杂布局$.fn.zIndex()
,集 取实际值、赋值、同辈置顶/沉底 功能于一身$.selectorPriority()
$.cssName()
$.searchCSS()
$.fn.uniqueId()
(jQuery UI 标准)$.fn.selection()
$.fn.focus()
会让所有可见元素获得焦点$.Observer()
$.customEvent()
事件扩展接口,并基于此实现 input
标准事件的补丁$.fn.onIdleFor()
$.fn.onReply()
(基于 window.postMessage()
)$.fn.animate()
支持类似 jQuery UI $.fn.effect()
动画效果名参数(基于 CSS Animation 实现)$.fn.toggleAnimate()
$.toBlob()
$.dataHash()
Number.isInteger()
整数判断方法Number.isSafeInteger()
安全整数判断方法String.prototype.trim()
(借鉴 PHP)String.prototype.repeat
标准方法String.prototype.padStart
标准方法String.prototype.padEnd
标准方法Array.from()
标准方法Array.prototype.indexOf()
标准方法Array.prototype.reduce()
标准方法Function.prototype.name
属性补丁Object.keys()
标准方法Object.getPrototypeOf()
标准方法Object.create()
标准方法Date.now()
标准方法Promise()
标准对象构造函数Error.prototype.valueOf()
,使 IE 10- 返回可查询的错误码(附带 官方文档 URL)HTMLDocument.prototype.currentScript
属性HTMLDocument.prototype.scrollingElement
属性remove()
、replaceWith()
实例方法Element.prototype.textContent
属性Element.prototype.innerHTML
的 IE 8 补丁Element.prototype.children
属性在其元素有 name 属性时的“数字键值缺失”BugfirstElementChild
、lastElementChild
、previousElementSibling
、nextElementSibling
属性Element.prototype.matches
标准草案方法<a />
、<area />
、<link />
、<svg />
等元素提供 classList、relList 属性支持HTMLSelectElement.prototype.selectedOptions
属性的 IE 补丁location.origin
、HTMLAnchorElement.prototype.origin
只读属性 IE 11- 补丁Window.getMatchedCSSRules()
Window.getMatchedCSSRules()
FormData()
标准对象构造函数,为 IE 10- 提供 表单数据封装DOMImplementation()
标准对象 createDocument
、createHTMLDocment
实例方法,为 IE 8 提供 XML / HTML 文档对象创建支持DOMParser()
标准对象构造函数,为 IE 8+ 提供 XML / SVG / HTML 文档代码解析支持URL()
标准对象构造函数URLSearchParams()
标准对象构造函数此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。