Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inferno-extras

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inferno-extras

Collection of utilities for InfernoJS

  • 8.2.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

inferno-extras

Is a collection of pure functions to ease some tasks with InfernoJS virtual DOM.

Install

npm install inferno-extras

isDOMInsideComponent

DOM - Html node

instance - Class component instance

Returns boolean:

  • true when DOM is found from children of given instance;
  • false when DOM node is not found.
import { isDOMInsideComponent } from 'inferno-extras';

isDOMInsideComponent(
  DOM,
  instance,
)

Motivation:

InfernoJS events bubble through the real DOM. This can cause issues when you need to for example: stop event propagation from all child Components. Native node.contains( otherNode ) returns false when Portal renders outside its root node. This utility method solves the problem using non recursive DFS algorithm.

Example:

import { Component } from 'inferno';
import { isDOMinsideVDOM } from 'inferno-extras';

class Clicker extends Component {

  isClickOutside(event) {
    // Check if click event came from any child component
    if (!isDOMInsideComponent(event.target, this) {
      this.setState({ closeMenu: true });
    }
  }

...
}

isDOMInsideVNode

Exactly same as isDOMInsideComponent but second parameter is virtual node.

Keywords

FAQs

Package last updated on 30 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc