New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@daeinc/dom

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daeinc/dom - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

12

dist/index.d.ts

@@ -8,7 +8,15 @@ /**

/**
* convert selector (string) to DOM Element. if already typeof Element, return as is.
* convert selector (string) to Element. if already typeof Element, return as is.
*
* @param selector
* @returns
*/
export declare const toDomElement: (selector: string | Element) => Element;
export declare const toElement: (selector: string | Element) => Element;
/**
* convert selector (string) to HTMLElement. if already typeof HTMLElement, return as is.
*
* @param selector
* @returns
*/
export declare const toHTMLElement: (selector: string | HTMLElement) => HTMLElement;
//# sourceMappingURL=index.d.ts.map

32

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toDomElement = exports.appendChild = void 0;
/**

@@ -9,6 +7,8 @@ * append child to parent. if parent is undefined, append child to body

*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.toHTMLElement = exports.toElement = exports.appendChild = void 0;
const appendChild = (parent, child) => {
child = (0, exports.toDomElement)(child);
child = (0, exports.toElement)(child);
if (parent !== undefined) {
parent = (0, exports.toDomElement)(parent);
parent = (0, exports.toElement)(parent);
parent.appendChild(child);

@@ -22,7 +22,8 @@ }

/**
* convert selector (string) to DOM Element. if already typeof Element, return as is.
* convert selector (string) to Element. if already typeof Element, return as is.
*
* @param selector
* @returns
*/
const toDomElement = (selector) => {
const toElement = (selector) => {
if (typeof selector === "string") {

@@ -37,3 +38,20 @@ const element = document.querySelector(selector);

};
exports.toDomElement = toDomElement;
exports.toElement = toElement;
/**
* convert selector (string) to HTMLElement. if already typeof HTMLElement, return as is.
*
* @param selector
* @returns
*/
const toHTMLElement = (selector) => {
if (typeof selector === "string") {
const element = document.querySelector(selector);
if (!element) {
throw new Error(`could not find the element with the selector: ${selector}`);
}
return element;
}
return selector;
};
exports.toHTMLElement = toHTMLElement;
//# sourceMappingURL=index.js.map
{
"name": "@daeinc/dom",
"version": "0.3.1",
"version": "0.4.0",
"description": "DOM utilities",

@@ -14,3 +14,3 @@ "types": "./dist/index.d.ts",

"demo": "parcel ./demo/demo.html --no-cache --dist-dir ./demo/build/",
"build": "npx tsc --build --clean && npx tsc --build"
"build": "tsc --build --clean && tsc --build"
},

@@ -17,0 +17,0 @@ "author": "Daeinc",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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