Skip to content

Commit

Permalink
fix: fix native insertBefore and insertAfter
Browse files Browse the repository at this point in the history
  • Loading branch information
idiotWu committed Dec 12, 2015
1 parent 3e59f0b commit 6ac0d28
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 74 deletions.
16 changes: 5 additions & 11 deletions README-id.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ Untuk selector-selector umum seperti class, id atau attribute, kita dapat menggu

- [1.9](#1.9) <a name='1.9'></a> Iframe Contents

`$('iframe').contents()` mengembalikan `contentDocument`
`$('iframe').contents()` mengembalikan `contentDocument`

+ Iframe contents

Expand Down Expand Up @@ -498,7 +498,8 @@ Untuk selector-selector umum seperti class, id atau attribute, kita dapat menggu
$newEl.insertBefore(queryString);
// Native
newEl.insertBefore(document.querySelector(queryString));
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target);
```

- [3.7](#3.7) <a name='3.7'></a> insertAfter
Expand All @@ -510,15 +511,8 @@ Untuk selector-selector umum seperti class, id atau attribute, kita dapat menggu
$newEl.insertAfter(queryString);
// Native
function insertAfter(newEl, queryString) {
const parent = document.querySelector(queryString).parentNode;
if (parent.lastChild === newEl) {
parent.appendChild(newEl);
} else {
parent.insertBefore(newEl, parent.nextSibling);
}
},
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target.nextSibling);
```

**[⬆ back to top](#daftar-isi)**
Expand Down
14 changes: 4 additions & 10 deletions README-my.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ Pemilihan elemen yang umum seperti class, id atau atribut, biasanya kita boleh p
$newEl.insertBefore(queryString);
// Native
newEl.insertBefore(document.querySelector(queryString));
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target);
```

- [3.7](#3.7) <a name='3.7'></a> insertAfter
Expand All @@ -494,15 +495,8 @@ Pemilihan elemen yang umum seperti class, id atau atribut, biasanya kita boleh p
$newEl.insertAfter(queryString);
// Native
function insertAfter(newEl, queryString) {
const parent = document.querySelector(queryString).parentNode;
if (parent.lastChild === newEl) {
parent.appendChild(newEl);
} else {
parent.insertBefore(newEl, parent.nextSibling);
}
},
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target.nextSibling);
```

**[⬆ back to top](#table-of-contents)**
Expand Down
18 changes: 6 additions & 12 deletions README-vi.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Ngày nay, môi trường lập trình front-end phát triển rất nhanh chón

// Native
document.querySelectorAll('.class');

// hoặc
document.getElementsByClassName('class');
```
Expand All @@ -54,7 +54,7 @@ Ngày nay, môi trường lập trình front-end phát triển rất nhanh chón

// Native
document.querySelector('#id');

// hoặc
document.getElementById('id');
```
Expand Down Expand Up @@ -499,7 +499,8 @@ Ngày nay, môi trường lập trình front-end phát triển rất nhanh chón
$newEl.insertBefore(queryString);
// Native
newEl.insertBefore(document.querySelector(queryString));
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target);
```

- [3.7](#3.7) <a name='3.7'></a> insertAfter
Expand All @@ -511,15 +512,8 @@ Ngày nay, môi trường lập trình front-end phát triển rất nhanh chón
$newEl.insertAfter(queryString);
// Native
function insertAfter(newEl, queryString) {
const parent = document.querySelector(queryString).parentNode;
if (parent.lastChild === newEl) {
parent.appendChild(newEl);
} else {
parent.insertBefore(newEl, parent.nextSibling);
}
},
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target.nextSibling);
```

**[⬆ Trở về đầu](#danh-mục)**
Expand Down
14 changes: 4 additions & 10 deletions README.ko-KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@
$newEl.insertBefore(queryString);
// Native
newEl.insertBefore(document.querySelector(queryString));
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target);
```

- [3.7](#3.7) <a name='3.7'></a> 해당 엘리먼트 뒤에 넣기(insertAfter)
Expand All @@ -509,15 +510,8 @@
$newEl.insertAfter(queryString);
// Native
function insertAfter(newEl, queryString) {
const parent = document.querySelector(queryString).parentNode;
if (parent.lastChild === newEl) {
parent.appendChild(newEl);
} else {
parent.insertBefore(newEl, parent.nextSibling);
}
},
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target.nextSibling);
```

**[⬆ 목차로 돌아가기](#목차)**
Expand Down
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ In place of common selectors like class, id or attribute we can use `document.qu
$newEl.insertBefore(queryString);
// Native
newEl.insertBefore(document.querySelector(queryString));
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target);
```

- [3.7](#3.7) <a name='3.7'></a> insertAfter
Expand All @@ -510,15 +511,8 @@ In place of common selectors like class, id or attribute we can use `document.qu
$newEl.insertAfter(queryString);
// Native
function insertAfter(newEl, queryString) {
const parent = document.querySelector(queryString).parentNode;
if (parent.lastChild === newEl) {
parent.appendChild(newEl);
} else {
parent.insertBefore(newEl, parent.nextSibling);
}
},
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target.nextSibling);
```

**[⬆ back to top](#table-of-contents)**
Expand Down
16 changes: 5 additions & 11 deletions README.pt-BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ No lugar de seletores comuns como classe, id ou atributo podemos usar `document.
```js
// jQuery
$el.next();
// Nativo
el.nextElementSibling;
```
Expand Down Expand Up @@ -503,7 +503,8 @@ No lugar de seletores comuns como classe, id ou atributo podemos usar `document.
$newEl.insertBefore(queryString);
// Nativo
newEl.insertBefore(document.querySelector(queryString));
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target);
```

- [3.7](#3.7) <a name='3.7'></a> insertAfter
Expand All @@ -515,15 +516,8 @@ No lugar de seletores comuns como classe, id ou atributo podemos usar `document.
$newEl.insertAfter(queryString);
// Nativo
function insertAfter(newEl, queryString) {
const parent = document.querySelector(queryString).parentNode;
if (parent.lastChild === newEl) {
parent.appendChild(newEl);
} else {
parent.insertBefore(newEl, parent.nextSibling);
}
},
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target.nextSibling);
```

**[⬆ ir para o topo](#tabela-de-conteúdos)**
Expand Down
14 changes: 4 additions & 10 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@
$newEl.insertBefore(queryString);
// Native
newEl.insertBefore(document.querySelector(queryString));
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target);
```

- [3.7](#3.7) <a name='3.7'></a> insertAfter
Expand All @@ -510,15 +511,8 @@
$newEl.insertAfter(queryString);
// Native
function insertAfter(newEl, queryString) {
const parent = document.querySelector(queryString).parentNode;
if (parent.lastChild === newEl) {
parent.appendChild(newEl);
} else {
parent.insertBefore(newEl, parent.nextSibling);
}
},
const target = document.querySelector(queryString);
target.parentNode.insertBefore(newEl, target.nextSibling);
```

**[⬆ 回到顶部](#目录)**
Expand Down

0 comments on commit 6ac0d28

Please sign in to comment.