Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[question] Node removeChild() set to null

オープン
#375 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript
領域
frontend

調査の方向性

core/Node の removeChild() から開始し、報告されたスニペット内の Dispatch.prototype.dispatch と _children の処理を比較してください。子を削除した後のイベントディスパッチを再現し、削除された子によって null へのアクセスが発生しなくなることを確認するとともに、意図された子リストの動作を維持してください。Node と dispatch に関する既存のテストがあれば確認してください。

索引モデルが issue の本文から書いたものです。

説明

question

When Node1.removeChild(node2) is called, the index of node2 in Node1._children array is set to NULL.
This causes an error when, after a removeChild, i use events:

Uncaught TypeError: Cannot read property 'onReceive' of null

here:

Dispatch.prototype.dispatch = function dispatch (event, payload) {
if (!event) throw new Error('dispatch requires an event name as it's first argument');

var queue = this._queue;
var item;
var i;
var len;
var children;

queue.length = 0;
queue.push(this._context);

while (queue.length) {
    item = queue.shift();
    if (item.onReceive) item.onReceive(event, payload);
    children = item.getChildren();
    for (i = 0, len = children.length ; i < len ; i++) queue.push(children[i]);
}

};

I managed to fix this, by changing:

this._children[index] = null;

with:

this._children.splice(index, 1);

in the removeChild() function of core/Node.

Is this intentional?
Does this change affect other things?

主要言語
JavaScript
スター
1.7k
フォーク
249
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Famous/engine のほかの issue

Famous/engine の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。