Skip to content

Commit 846cb73

Browse files
committed
【新增】ChildNode 接口的 remove()、replaceWith() 实例方法补丁
【移除】$.fn.sandBox() 由 $.fn.load() 和 DOMParser() 代替 【优化】精简多处代码写法
1 parent dbb40d9 commit 846cb73

File tree

21 files changed

+2397
-2515
lines changed

21 files changed

+2397
-2515
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/terHRJgDULkGjswWhddcBSDJ/TechQuery/iQuery.js.svg' />
99
</a>
1010

11-
在 API 形态上尽力兼容 jQuery 的同时,iQuery 在内部实现上采取 **“面向未来,向前兼容”的 Polyfill 策略** —— 核心逻辑(4300+ 行)尽力基于 **W3C、ECMA 最新标准中的优秀 API**,老旧浏览器兼容代码(部分基于 jQuery API,1200+ 行)尽力包装成与新 API 相同的形式(原型拓展),并独立为外部模块。这样做不但能复用 jQuery API 来高效实现,还方便开发人员自行裁剪。
11+
在 API 形态上尽力兼容 jQuery 的同时,iQuery 在内部实现上采取 **“面向未来,向前兼容”的 Polyfill 策略** —— jQuery 标准 API(2500 行)、iQuery 扩展 API(1800 行)尽力基于 **W3C、ECMA 最新标准中的优秀 API**,老旧浏览器兼容代码(部分基于 jQuery API,1200+ 行)尽力包装成与新 API 相同的形式(原型拓展),并独立为外部模块。这样做不但能复用 jQuery API 来高效实现,还方便开发人员自行裁剪。
1212

1313
【注】对 IE 的兼容仅限其“标准模式”,而非“兼容性视图”。
1414

@@ -158,6 +158,7 @@
158158
- 新增 **HTMLHttpRequest 对象**,封装了 **JSONP Get****iframe Post**
159159
- 自带 `HTMLDocument.prototype.currentScript` 属性
160160
- 自带 `HTMLDocument.prototype.scrollingElement` 属性
161+
- 自带 **ChildNode 接口**`remove()``replaceWith()` 实例方法
161162
- 自带 `Element.prototype.textContent` 属性
162163
- 自带 `Element.prototype.innerHTML` 的 IE 8 补丁
163164
- 自带 **HTMLCollection 对象**,修复 IE 10- `Element.prototype.children` 属性在其元素有 name 属性时的“数字键值缺失”Bug

build/iQuery.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/iQuery.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/$.html

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,7 @@ <h4 class="name" id=".bitOperate"><span class="type-signature">(static) </span>b
181181

182182
<h5>Example</h5>
183183

184-
<pre class="prettyprint"><code>// 按位或
185-
186-
$.bitOperate('|', '10'.repeat(16), '01'.repeat(16))
187-
188-
// '1'.repeat(32)</code></pre>
184+
<pre class="prettyprint"><code>// 按位或 $.bitOperate('|', '10'.repeat(16), '01'.repeat(16)) // '1'.repeat(32)</code></pre>
189185

190186
<h5>Parameters:</h5>
191187

@@ -521,11 +517,7 @@ <h4 class="name" id=".extendURL"><span class="type-signature">(static) </span>ex
521517

522518
<h5>Example</h5>
523519

524-
<pre class="prettyprint"><code>// 多种参数
525-
526-
$.extendURL('path/to/model?a=0', 'a=1&amp;b=1', {b: 2, c: 3})
527-
528-
// 'path/to/model?a=1&amp;b=2&amp;c=3'</code></pre>
520+
<pre class="prettyprint"><code>// 多种参数 $.extendURL('path/to/model?a=0', 'a=1&amp;b=1', {b: 2, c: 3}) // 'path/to/model?a=1&amp;b=2&amp;c=3'</code></pre>
529521

530522
<h5>Parameters:</h5>
531523

@@ -701,19 +693,11 @@ <h4 class="name" id=".hyphenCase"><span class="type-signature">(static) </span>h
701693

702694
<h5>Examples</h5>
703695

704-
<pre class="prettyprint"><code>// 符号间隔
705-
706-
$.hyphenCase('UPPER_CASE') // 'upper-case'</code></pre>
707-
708-
<pre class="prettyprint"><code>// 驼峰法
709-
710-
$.hyphenCase('camelCase') // 'camel-case'</code></pre>
711-
712-
<pre class="prettyprint"><code>// 混杂写法
696+
<pre class="prettyprint"><code>// 符号间隔 $.hyphenCase('UPPER_CASE') // 'upper-case'</code></pre>
713697

714-
$.hyphenCase('UPPER_CASEMix -camelCase')
698+
<pre class="prettyprint"><code>// 驼峰法 $.hyphenCase('camelCase') // 'camel-case'</code></pre>
715699

716-
// 'upper-case-mix-camel-case'</code></pre>
700+
<pre class="prettyprint"><code>// 混杂写法 $.hyphenCase('UPPER_CASEMix -camelCase') // 'upper-case-mix-camel-case'</code></pre>
717701

718702
<h5>Parameters:</h5>
719703

@@ -1565,17 +1549,11 @@ <h4 class="name" id=".split"><span class="type-signature">(static) </span>split<
15651549

15661550
<h5>Examples</h5>
15671551

1568-
<pre class="prettyprint"><code>// 原型方法等效
1552+
<pre class="prettyprint"><code>// 原型方法等效 $.split('abc', '') // ['a', 'b', 'c']</code></pre>
15691553

1570-
$.split('abc', '') // ['a', 'b', 'c']</code></pre>
1554+
<pre class="prettyprint"><code>// PHP str_split() 等效 $.split('abc', '', 2) // ['a', 'bc']</code></pre>
15711555

1572-
<pre class="prettyprint"><code>// PHP str_split() 等效
1573-
1574-
$.split('abc', '', 2) // ['a', 'bc']</code></pre>
1575-
1576-
<pre class="prettyprint"><code>// 连接字符串
1577-
1578-
$.split("a b\tc", /\s+/, 2, ' ') // ['a', 'b c']</code></pre>
1556+
<pre class="prettyprint"><code>// 连接字符串 $.split("a b\tc", /\s+/, 2, ' ') // ['a', 'b c']</code></pre>
15791557

15801558
<h5>Parameters:</h5>
15811559

@@ -2300,7 +2278,7 @@ <h5>Returns:</h5>
23002278
</dd>
23012279
</dl>
23022280

2303-
<h4 class="name" id="insertTo"><span class="type-signature"></span>insertTo<span class="signature">($_Target, Index<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="$.html">$</a>}</span></h4>
2281+
<h4 class="name" id="insertTo"><span class="type-signature"></span>insertTo<span class="signature">($_Target, index<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="$.html">$</a>}</span></h4>
23042282

23052283
<dl class="details">
23062284

@@ -2324,21 +2302,9 @@ <h4 class="name" id="insertTo"><span class="type-signature"></span>insertTo<span
23242302

23252303
<h5>Examples</h5>
23262304

2327-
<pre class="prettyprint"><code>// 插入到最前
2328-
2329-
$('&lt;a>insert&lt;/a>').insertTo('body') &amp;&amp; (
2330-
$('body > :first-child')[0].textContent
2331-
)
2332-
2333-
// 'insert'</code></pre>
2334-
2335-
<pre class="prettyprint"><code>// 插入到最后
2336-
2337-
$('&lt;a>insert&lt;/a>').insertTo('body', Infinity) &amp;&amp; (
2338-
$('body > :last-child')[0].textContent
2339-
)
2305+
<pre class="prettyprint"><code>// 插入到最前 $('&lt;a>insert&lt;/a>').insertTo('body') &amp;&amp; ( $('body > :first-child')[0].textContent ) // 'insert'</code></pre>
23402306

2341-
// 'insert'</code></pre>
2307+
<pre class="prettyprint"><code>// 插入到最后 $('&lt;a>insert&lt;/a>').insertTo('body', Infinity) &amp;&amp; ( $('body > :last-child')[0].textContent ) // 'insert'</code></pre>
23422308

23432309
<h5>Parameters:</h5>
23442310

@@ -2383,7 +2349,7 @@ <h5>Parameters:</h5>
23832349

23842350
<tr>
23852351

2386-
<td class="name"><code>Index</code></td>
2352+
<td class="name"><code>index</code></td>
23872353

23882354
<td class="type">
23892355

docs/DOM_ext_base.js.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ <h1 class="page-title">DOM/ext/base.js</h1>
5252
* @return {DocumentFragment}
5353
*/
5454

55-
$.buildFragment = $.buildFragment || function (iNode) {
55+
$.buildFragment = $.buildFragment || function (node) {
5656

57-
iNode = $.makeArray( iNode );
57+
node = $.makeArray( node );
5858

59-
var iFragment = (arguments[1] || document).createDocumentFragment();
59+
var fragment = (arguments[1] || document).createDocumentFragment();
6060

61-
for (var i = 0; iNode[i]; i++) iFragment.appendChild( iNode[i] );
61+
for (var i = 0; node[i]; i++) fragment.appendChild( node[i] );
6262

63-
return iFragment;
63+
return fragment;
6464
};
6565

6666
/**
@@ -72,7 +72,7 @@ <h1 class="page-title">DOM/ext/base.js</h1>
7272
* @function insertTo
7373
*
7474
* @param {jQueryAcceptable} $_Target
75-
* @param {number} [Index=0] Position index of `$_Target`'s
75+
* @param {number} [index=0] Position index of `$_Target`'s
7676
* child Elements
7777
*
7878
* @return {$} All the Elements inserted
@@ -94,7 +94,7 @@ <h1 class="page-title">DOM/ext/base.js</h1>
9494
* // 'insert'
9595
*/
9696

97-
$.fn.insertTo = function ($_Target, Index) {
97+
$.fn.insertTo = function ($_Target, index) {
9898

9999
var DOM_Set = $.buildFragment(this, document), $_This = [ ];
100100

@@ -104,7 +104,7 @@ <h1 class="page-title">DOM/ext/base.js</h1>
104104

105105
$.merge($_This, DOM_Set.children);
106106

107-
this.insertBefore(DOM_Set, this.children[Index || 0]);
107+
this.insertBefore(DOM_Set, this.children[index || 0]);
108108
});
109109

110110
return this.pushStack( $_This );

docs/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="$.html">$
3131
<article><h1>iQuery</h1><p>兼容 <a href="http://api.jquery.com/">jQuery API</a> 的 DOM / AJAX 基础库,基于原创的 ECMA / W3C polyfill 构建,并内置很多常用的 jQuery 扩展 API。</p>
3232
<p><a href="https://gitter.im/iQuery-js/Lobby?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge"><img src="https://badges.gitter.im/iQuery-js/Lobby.svg" alt="Join the chat at https://gitter.im/iQuery-js/Lobby"></a></p>
3333
<p><a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/terHRJgDULkGjswWhddcBSDJ/TechQuery/iQuery.js'><br> <img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/terHRJgDULkGjswWhddcBSDJ/TechQuery/iQuery.js.svg' /><br></a></p>
34-
<p>在 API 形态上尽力兼容 jQuery 的同时,iQuery 在内部实现上采取 <strong>“面向未来,向前兼容”的 Polyfill 策略</strong> —— 核心逻辑(4300+ 行)尽力基于 <strong>W3C、ECMA 最新标准中的优秀 API</strong>,老旧浏览器兼容代码(部分基于 jQuery API,1200+ 行)尽力包装成与新 API 相同的形式(原型拓展),并独立为外部模块。这样做不但能复用 jQuery API 来高效实现,还方便开发人员自行裁剪。</p>
34+
<p>在 API 形态上尽力兼容 jQuery 的同时,iQuery 在内部实现上采取 <strong>“面向未来,向前兼容”的 Polyfill 策略</strong> —— jQuery 标准 API(2500 行)、iQuery 扩展 API(1800 行)尽力基于 <strong>W3C、ECMA 最新标准中的优秀 API</strong>,老旧浏览器兼容代码(部分基于 jQuery API,1200+ 行)尽力包装成与新 API 相同的形式(原型拓展),并独立为外部模块。这样做不但能复用 jQuery API 来高效实现,还方便开发人员自行裁剪。</p>
3535
<p>【注】对 IE 的兼容仅限其“标准模式”,而非“兼容性视图”。</p>
3636
<h2>【竞品比较】</h2><table>
3737
<thead>
@@ -215,6 +215,7 @@ <h3>ECMA、W3C 标准 API 补丁</h3><ul>
215215
<li>新增 <strong>HTMLHttpRequest 对象</strong>,封装了 <strong>JSONP Get</strong><strong>iframe Post</strong></li>
216216
<li>自带 <code>HTMLDocument.prototype.currentScript</code> 属性</li>
217217
<li>自带 <code>HTMLDocument.prototype.scrollingElement</code> 属性</li>
218+
<li>自带 <strong>ChildNode 接口</strong><code>remove()</code><code>replaceWith()</code> 实例方法</li>
218219
<li>自带 <code>Element.prototype.textContent</code> 属性</li>
219220
<li>自带 <code>Element.prototype.innerHTML</code> 的 IE 8 补丁</li>
220221
<li>自带 <strong>HTMLCollection 对象</strong>,修复 IE 10- <code>Element.prototype.children</code> 属性在其元素有 name 属性时的“数字键值缺失”Bug</li>

docs/index.js.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h1 class="page-title">index.js</h1>
3535
* iQuery.js - A Light-weight jQuery Compatible API with IE 8+ compatibility
3636
*
3737
* @module {function} iQuery
38-
* @version 3.0 (2018-02-01) stable
38+
* @version 3.1 (2018-02-08) stable
3939
*
4040
* @copyright TechQuery &lt;shiy2008@gmail.com> 2015-2018
4141
* @license GPL-2.0-or-later
@@ -45,7 +45,7 @@ <h1 class="page-title">index.js</h1>
4545

4646
define([
4747
'./iQuery',
48-
'./DOM/insert', './DOM/ext/selection',
48+
'./DOM/ext/utility', './DOM/ext/selection',
4949
'./CSS/ext/rule', './CSS/ext/utility',
5050
'./event/ext/shim', './event/ext/wrapper',
5151
'./AJAX/ext/wrapper', './AJAX/ext/form',

docs/module-iQuery.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h1 class="page-title">iQuery</h1>
4848
</li></ul></dd>
4949

5050
<dt class="tag-version">Version:</dt>
51-
<dd class="tag-version"><ul class="dummy"><li>3.0 (2018-02-01) stable</li></ul></dd>
51+
<dd class="tag-version"><ul class="dummy"><li>3.1 (2018-02-08) stable</li></ul></dd>
5252

5353
<dt class="tag-copyright">Copyright:</dt>
5454
<dd class="tag-copyright"><ul class="dummy"><li>TechQuery <shiy2008@gmail.com> 2015-2018</li></ul></dd>

0 commit comments

Comments
 (0)