[question] Node removeChild() set to null
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript
- 领域
- frontend
调研方向
从 core/Node 中的 removeChild() 开始,将其对 _children 的处理与所报告代码片段中的 Dispatch.prototype.dispatch 进行比较。重现移除子节点后的事件分发,然后验证被移除的子节点不再导致对 null 的访问,同时保留预期的子节点列表行为;如果存在,检查 Node 和 dispatch 周围的现有测试。
由索引模型根据 Issue 内容生成。
描述
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
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Famous/engine 的其他 Issue
-
mechronetech未关闭
难度 5/5 一周以上 新手友好度 5/100
-
难度 5/5 一周以上 新手友好度 1/100
-
难度 1/5 1 小时以内 新手友好度 1/100
-
#THEREISNOSPOON未关闭
难度 5/5 一周以上 新手友好度 10/100
-
难度 5/5 一周以上 新手友好度 10/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 8 天内回复
-
docs(stream-protocol): document messageMetatadata on start/finish and the message-metadata chunk未关闭factory-active task-identify-harness-labels-done task-identify-issue-type-done
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
feature request
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
docs hacktoberfest help wanted
难度 2/5 1-3 小时 新手友好度 85/100
pacocartones/free-llm-api-hub#347 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
wpilibsuite/wpilib-docs#3378 ·
维护者通常 1 天内回复