Registry / serialization / dom-node-types

dom-node-types

JSON →
library1.0.1jsnpmunverified

This package `dom-node-types` (version 1.0.1) provides a lightweight solution for accessing the numeric constants associated with standard DOM Node types, such as `ELEMENT_NODE`, `TEXT_NODE`, and `COMMENT_NODE`. Its primary purpose is to offer these well-defined constants directly, enabling developers to avoid the necessity of including a full-fledged DOM implementation as a dependency when only these specific values are required for logic, type checking, or comparison. The package is maintained with a stable, low-cadence release cycle, reflecting its simple and immutable utility. Its key differentiator lies in its focused minimalism, providing essential DOM constants without introducing any additional overhead, browser API polyfills, or complex parsing capabilities, making it ideal for environments where a full DOM is unavailable or unnecessary.

npm install dom-node-types
INSTALL
IMPORT
SIG · DOM-NODE-TYPES
D
dom-node-types
serializationjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ELEMENT_NODE
import { ELEMENT_NODE } from 'dom-node-types';
import ELEMENT_NODE from 'dom-node-types';
For accessing individual DOM Node type constants using named ESM imports.
nodeTypes (wildcard)
import * as nodeTypes from 'dom-node-types';
import nodeTypes from 'dom-node-types';
Imports all available DOM Node type constants into a single `nodeTypes` object in ESM environments.
CommonJS (all)
const nodeTypes = require('dom-node-types');
import { ELEMENT_NODE } from 'dom-node-types';
Retrieves an object containing all DOM Node type constants for CommonJS environments. Avoid `import` syntax in pure CJS files.
CommonJS (individual)
const { ELEMENT_NODE } = require('dom-node-types');
var ELEMENT_NODE = require('dom-node-types'); // only assigns the module object, not the constant directly
Destructures a specific DOM Node type constant directly from the CommonJS export object.

Demonstrates how to import and access specific DOM Node type constants, as well as how to import all constants as a single object.

import { ELEMENT_NODE, TEXT_NODE, COMMENT_NODE } from 'dom-node-types'; console.log('DOM Node Types Constants:'); console.log(`ELEMENT_NODE: ${ELEMENT_NODE}`); // Expected: 1 console.log(`TEXT_NODE: ${TEXT_NODE}`); // Expected: 3 console.log(`COMMENT_NODE: ${COMMENT_NODE}`); // Expected: 8 // You can also import all as an object import * as nodeTypes from 'dom-node-types'; console.log(`\nAll types object:`); console.log(`nodeTypes.DOCUMENT_NODE: ${nodeTypes.DOCUMENT_NODE}`); // Expected: 9 console.log(`nodeTypes.CDATA_SECTION_NODE: ${nodeTypes.CDATA_SECTION_NODE}`); // Expected: 4 // This package is purely for constants, it does not interact with actual DOM elements.
Debug
Known issues
gotchaThis package only exports numeric constants representing DOM Node types. It does not provide any DOM manipulation utilities, polyfills, or interaction with actual DOM elements.
fix
Understand its scope as solely a constant provider. Do not expect it to offer methods for creating or manipulating DOM nodes.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: (0 , dom_node_types__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_NODE) is not a function
Attempting to call an imported constant as if it were a function, or a bundler/runtime misinterpreting the export type, often due to mixed ESM/CJS environments.
fix
Ensure `ELEMENT_NODE` is treated as a numeric constant, not a callable function. Verify correct import syntax for your module environment (ESM `import { ELEMENT_NODE }` or CJS `const { ELEMENT_NODE } = require`).
ReferenceError: ELEMENT_NODE is not defined
The constant `ELEMENT_NODE` was used without being correctly imported or destructured from the `dom-node-types` package.
fix
Add the appropriate import statement at the top of your file. For ESM: `import { ELEMENT_NODE } from 'dom-node-types';`. For CommonJS: `const { ELEMENT_NODE } = require('dom-node-types');`.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
dom-node-types — npm install dom-node-types · libregistry