teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

remove の存在判定アルゴリズムを変更

2016/04/11 01:42

投稿

think49
think49

スコア18194

answer CHANGED
@@ -15,7 +15,7 @@
15
15
  - [ChildNode.remove() - Web API インターフェイス | MDN](https://developer.mozilla.org/ja/docs/Web/API/ChildNode/remove)
16
16
 
17
17
  ```JavaScript
18
- if (typeof Element === 'function' && !('remove' in Element.prototype)) { // IE11- 用の Polyfill
18
+ if (typeof Element === 'function' && !('remove' in document.createElement('p'))) { // IE11- 用の Polyfill
19
19
  Element.prototype.remove = function remove () {
20
20
  if (this.parentNode) {
21
21
  this.parentNode.removeChild(this);