Skip to content

Only removeChild valid children in DomRenderer dispose#2962

Merged
Tyriar merged 3 commits intoxtermjs:masterfrom
JoshuaKGoldberg:dom-renderer-dispose-children
Jun 4, 2020
Merged

Only removeChild valid children in DomRenderer dispose#2962
Tyriar merged 3 commits intoxtermjs:masterfrom
JoshuaKGoldberg:dom-renderer-dispose-children

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Contributor

Fixes #2960

I did a scan for where I should add unit tests but it looks like the DOM renderer itself isn't unit tested - just DomRendererRowFactory.

Comment thread src/browser/renderer/dom/DomRenderer.ts Outdated
Comment on lines +107 to +109
if (element.parentElement === this._screenElement) {
this._screenElement.removeChild(element);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work instead to be more concise?

this.._rowContainer.parentNode?.removeChild(this._rowContainer);

We could also start a browser/Dom.ts for helpers like this: removeFromParent(...elements: HTMLElement[])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that works, yes! Updated.

For browser/Dom.ts, I'll let you do that 😄 I don't have a good feeling for this repository's style preferences.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helper: #2966

@Tyriar Tyriar added this to the 4.7.0 milestone Jun 4, 2020
@Tyriar Tyriar self-assigned this Jun 4, 2020
@Tyriar Tyriar merged commit fb25be3 into xtermjs:master Jun 4, 2020
@JoshuaKGoldberg JoshuaKGoldberg deleted the dom-renderer-dispose-children branch June 4, 2020 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

2 participants