This package has been deprecated

Author message:

Moved to @mojule/html

html-node

0.1.1 • Public • Published

html-node

Information about the node types used in HTML - what categories do elements or nodes belong to, can you put a given node inside another node etc.

Mostly for elements but functions can also take a nodeName eg. #text

const info = require( 'html-node' )
 
// tagNames() => [string]
console.log( info.tagNames() )
 
// categoryNames() => [string]
console.log( info.categoryNames() )
 
// isEmpty( nodeName: string ) => boolean
console.log( info.isEmpty( 'img' ) ) // true
console.log( info.isEmpty( 'div' ) ) // false
 
// isMetadata( nodeName: string ) => boolean
console.log( info.isMetadata( 'head' ) ) // true
console.log( info.isMetadata( 'div' ) ) // false
 
// isInline( nodeName: string ) => boolean
console.log( info.isInline( 'span' ) ) // true
console.log( info.isInline( '#text' ) ) // true
console.log( info.isInline( 'div' ) ) // false
 
// isEmbedded( nodeName: string ) => boolean
console.log( info.isEmbedded( 'img' ) ) // true
console.log( info.isEmbedded( 'div' ) ) // false
 
// isBlock( nodeName: string ) => boolean
console.log( info.isBlock( 'div' ) )  // true
console.log( info.isBlock( 'span' ) ) // false
 
// isContainer( nodeName: string )
console.log( info.isContainer( 'div' ) ) // true
console.log( info.isContainer( 'img' ) ) // false
 
// accepts( parentNodeName: string, childNodeName: string )
console.log( info.accepts( 'div', 'span' ) ) // true
console.log( info.accepts( 'span', 'div' ) ) // false
 
// def( nodeName ) => object
console.log( info.def( 'div' ) )

Readme

Keywords

Package Sidebar

Install

npm i html-node

Weekly Downloads

4

Version

0.1.1

License

MIT

Last publish

Collaborators

  • nrkn
  • andybell