Expand events tutorials to cover cases where bound elements are removed and re-added.
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
調査の方向性
既存のイベントチュートリアルと .remove() のドキュメントから始め、動機となる例として委譲された .on('click', '.someChild', ...) の例を使用します。バインドされた要素が削除されて再追加されたときに何が起こるかを、.html() による削除も含めて説明するようチュートリアルを拡張し、.detach() がハンドラーを保持する場合を明確にします。
索引モデルが issue の本文から書いたものです。
説明
Originally filed in jquery/api.jquery.com#632.
There seems to be pretty regular confusion surrounding the notion that event bindings break if the element you bound to was removed from the document (via, say, .remove()) and then re-added (like when you create a new element with $()).
The specific issue is that people think that simply using a delegated listener is enough - e.g.:
$('.someDiv').on('click', '.someChild', function() {
$('.someDiv').remove();
});
They then later re-add $('.someDiv') and expect this to work because the handler is technically bound to an element that exists at the time of binding - it just happened to be removed and re-added.
The .remove() docs helpfully explain that:
In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed. To remove the elements without removing data and events, use
.detach()instead.
This is fine, except that a lot of people aren't going to think to go to docs for .remove() while reading about events. This also doesn't cover cases where somebody ran something like .html('<span>no cookie for you</span>') on a parent of the bound node, wiping it out.
- 主要言語
- JavaScript
- スター
- 914
- フォーク
- 472
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
jquery/learn.jquery.com のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
jquery/learn.jquery.com#828 ·
-
Word(s) missing in article?再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンChapter: events
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
jquery/learn.jquery.com#751 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
jquery/learn.jquery.com#814 · コメント 1 件 ·
-
Chapter: jquery-core help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
jquery/learn.jquery.com#799 ·
-
Chapter: plugins
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
jquery/learn.jquery.com#796 ·
jquery/learn.jquery.com の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
good first issue help wanted javascript up-for-grabs
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
andrewsiah/agentswarm-data-tasks#307 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
coder/claudecode.nvim#588 ·
メンテナーはふだん 1 日以内に返信
-
area: web tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
digitalbazaar/http-client#60 ·