Skip to content

Memory leak when stylesheets removed #690

@peller

Description

@peller

Replacing/removing a DOM tree with a stylesheet with a call such as

head.innerHTML = "";

will result in a leak as the stylesheet is not removed from Document.styleSheets. There's a TODO in core.Document.prototype.__defineGetter__ for the styleSheets property that suggests a solution:

  // TODO: each style and link element should register its sheet on creation                                               
  // nad remove it on removal.                                                                                             

For a workaround, I'm iterating through ownerDocument.styleSheets and deleting its (array) properties, then setting styleSheets._length=0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions