How to use the diffhtml.release function in diffhtml

To help you get started, we’ve selected a few diffhtml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tbranyen / diffhtml / packages / diffhtml-components / lib / shared / lifecycle / component-will-unmount.js View on Github external
[...ComponentTreeCache.keys()].forEach(key => {
      if (NodeCache.has(key) && hasVTree(vTree, key)) {
        release(NodeCache.get(key));
      }
    });
  }

  // Ensure this is a stateful component. Stateless components do not get
  // lifecycle events yet.
  if (instance && instance.componentWillUnmount) {
    instance.componentWillUnmount();
  }

  // Clean up Shadow DOM (TODO what if the shadow dom is detached?).
  if (Constructor && NodeCache.has(vTree)) {
    release(NodeCache.get(vTree).shadowRoot);
  }

  // FIXME We release memory based on the DOM Node. This call is failing
  // because when the component renders we are setting a new renderTree to
  // associate
  release(NodeCache.get(vTree));

  ComponentTreeCache.delete(vTree);
  InstanceCache.delete(componentTree);
}
github tbranyen / diffhtml / packages / diffhtml-components / lib / shared / lifecycle / component-will-unmount.js View on Github external
// Ensure this is a stateful component. Stateless components do not get
  // lifecycle events yet.
  if (instance && instance.componentWillUnmount) {
    instance.componentWillUnmount();
  }

  // Clean up Shadow DOM (TODO what if the shadow dom is detached?).
  if (Constructor && NodeCache.has(vTree)) {
    release(NodeCache.get(vTree).shadowRoot);
  }

  // FIXME We release memory based on the DOM Node. This call is failing
  // because when the component renders we are setting a new renderTree to
  // associate
  release(NodeCache.get(vTree));

  ComponentTreeCache.delete(vTree);
  InstanceCache.delete(componentTree);
}
github mAAdhaTTah / brookjs / packages / brookjs-desalinate / src / elements.js View on Github external
export function release(el) {
    diffRelease(el);
    document.body.removeChild(el);
    elements.delete(el);
}