Skip to content

Should .dispose() be a trapdoor function? #3939

@xobs

Description

@xobs

As part of lifecycle management, xterm.dispose() exists to dispose of a terminal object. The documentation states that this function:

    /*
     * Disposes of the terminal, detaching it from the DOM and removing any
     * active listeners.
     */
    dispose(): void;

However, as part of this process, it also overwrites the .write() call, making the terminal no longer usable.

It seems as though the opposite would be open():

    /**
     * Opens the terminal within an element.
     * @param parent The element to create the terminal within. This element
     * must be visible (have dimensions) when `open` is called as several DOM-
     * based measurements need to be performed when this function is called.
     */
    open(parent: HTMLElement): void;

Should this be the case? Should .open() reinstate the .write() call? Or should the documentation be updated to reflect the fact that this is an error, and perhaps a warning be added to .write() or .open() to indicate the user is using a terminal that has been disposed of?

This is an extension of the discussion from #3910

Metadata

Metadata

Assignees

Labels

type/documentationRegarding website, API documentation, README, etc.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions