Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@degjs/dom-utils
Advanced tools
Working with the browser's Document Object Model (DOM) via JavaScript has historically been harder than it should be, filled with enough inconsistencies and browser bugs to drive even the best developer crazy. These challenges were a huge factor in the ubiquity of JavaScript helper libraries such as jQuery across the web.
Fortunately, those days are largely behind us. Modern-day DOM interaction is simpler and more consistent, to the point where jQuery shouldn't be an assumed dependency anymore (no, really).
domUtils bridges the gap between vanilla JS and a full-fledged library. It's a collection of helper methods that can be imported individually to keep your codebase lean, or together when more are needed.
domUtils is an ES6 module. Consequently, you'll need an ES6 transpiler (Babel is a nice one) as part of your Javascript workflow.
If you're already using NPM for your project, you can install domUtils with the following command:
$ npm install @degjs/dom-utils
import { createElement } from "@degjs/dom-utils";
let newEl = createElement('div', ['classNameA', 'classNameB']); // Create a new element
document.body.appendChild(newEl); // Add the new element to the DOM
import * as domUtils from "@degjs/dom-utils";
let newEl = domUtils.createElement('div', ['classNameA', 'classNameB']); // Create a new element
document.body.appendChild(newEl); // Add the new element to the DOM
domUtils.removeElements(newEl); // Remove the new element from the DOM
The isElement method tests a supplied value to see if it's a valid HTML element, and returns true
or false
.
Type: Element
The potential element to test.
Type: String
The name of the new HTML element you want to create (i.e., 'div', 'li', etc.).
Type: String
or Array
An indivudal class name, or array of class names, that will be added to the returned element.
The emptyElements method removes all child elements from the supplied list of HTML elements.
Type: Element
or Array
A single HTML element or an array of HTML elements that will be emptied.
The replaceContent method replaces an element's content with the supplied new content.
Type: Element
A single HTML element that will have its content replaced.
Type: String
The content that will replace the element's old content.
The removeElements method removes all supplied HTML elements from the DOM.
Type: Element
or Array
A single HTML element or an array of HTML elements that will be removed.
The wrapElements method wraps all supplied HTML elements within another supplied element.
Type: Element
or Array
A single HTML element or an array of HTML elements that will be wrapped by the wrapperEl
element.
Type: Element
A single HTML element that will be wrapped around the supplied elsToWrap
elements.
The unwrapElements method removes a wrapping parent HTML element, leaving all of its child elements in place.
Type: Element
or Array
A single HTML element or an array of HTML elements that will be removed, without removing child elements.
domUtils depends on the following browser APIs:
To support legacy browsers, you'll need to include polyfills for the above APIs.
FAQs
A utility library for working with the DOM.
We found that @degjs/dom-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.