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

@fluentui/dom-utilities

Package Overview
Dependencies
Maintainers
12
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fluentui/dom-utilities

DOM utilities for use within Fluent web components

  • 2.3.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
169K
decreased by-7.13%
Maintainers
12
Weekly downloads
 
Created

What is @fluentui/dom-utilities?

@fluentui/dom-utilities is a collection of utility functions for DOM manipulation and event handling, designed to be used with Fluent UI components. It provides a set of tools to simplify common tasks such as element positioning, event handling, and DOM traversal.

What are @fluentui/dom-utilities's main functionalities?

Event Handling

This feature provides utility functions to add and remove event listeners from DOM elements. It simplifies the process of managing event listeners.

const { addEventListener, removeEventListener } = require('@fluentui/dom-utilities');

const button = document.getElementById('myButton');

function handleClick(event) {
  console.log('Button clicked!');
}

addEventListener(button, 'click', handleClick);

// Later, to remove the event listener
removeEventListener(button, 'click', handleClick);

Element Positioning

This feature allows you to get the position and size of a DOM element. It returns an object with properties like top, left, width, and height.

const { getRect } = require('@fluentui/dom-utilities');

const element = document.getElementById('myElement');
const rect = getRect(element);

console.log(`Element position: ${rect.top}, ${rect.left}`);

DOM Traversal

This feature provides a utility function to recursively find a DOM element that matches a given condition. It simplifies the process of searching through the DOM tree.

const { findElementRecursive } = require('@fluentui/dom-utilities');

const rootElement = document.getElementById('root');
const targetElement = findElementRecursive(rootElement, (el) => el.id === 'target');

if (targetElement) {
  console.log('Target element found:', targetElement);
} else {
  console.log('Target element not found');
}

Other packages similar to @fluentui/dom-utilities

FAQs

Package last updated on 11 Oct 2024

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