2.0.0 • Published 3 years ago

dom-serializer v2.0.0

Weekly downloads
19,046,265
License
MIT
Repository
github
Last release
3 years ago

dom-serializer Build Status

Renders a domhandler DOM node or an array of domhandler DOM nodes to a string.

import render from "dom-serializer";

// OR

const render = require("dom-serializer").default;

API

render

render(node: Node | Node[], options?: Options): string

Renders a DOM node or an array of DOM nodes to a string.

Can be thought of as the equivalent of the outerHTML of the passed node(s).

Parameters:

NameTypeDefault valueDescription
nodeNode | Node[]-Node to be rendered.
optionsDomSerializerOptions{}Changes serialization behavior

Returns: string

Options

encodeEntities

Optional decodeEntities: boolean | "utf8"

Encode characters that are either reserved in HTML or XML.

If xmlMode is true or the value not 'utf8', characters outside of the utf8 range will be encoded as well.

default decodeEntities


decodeEntities

Optional decodeEntities: boolean

Option inherited from parsing; will be used as the default value for encodeEntities.

default true


emptyAttrs

Optional emptyAttrs: boolean

Print an empty attribute's value.

default xmlMode

example With emptyAttrs: false: <input checked>

example With emptyAttrs: true: <input checked="">


selfClosingTags

Optional selfClosingTags: boolean

Print self-closing tags for tags without contents.

default xmlMode

example With selfClosingTags: false: <foo></foo>

example With selfClosingTags: true: <foo />


xmlMode

Optional xmlMode: boolean | "foreign"

Treat the input as an XML document; enables the emptyAttrs and selfClosingTags options.

If the value is "foreign", it will try to correct mixed-case attribute names.

default false


Ecosystem

NameDescription
htmlparser2Fast & forgiving HTML/XML parser
domhandlerHandler for htmlparser2 that turns documents into a DOM
domutilsUtilities for working with domhandler's DOM
css-selectCSS selector engine, compatible with domhandler's DOM
cheerioThe jQuery API for domhandler's DOM
dom-serializerSerializer for domhandler's DOM

LICENSE: MIT

domutilscheeriocomponennenttvuedragdropuploadimagescheerio-without-node-native-rn@cashremit/cr-streamline-iconscloud-archive-s3bb-chat@fundefund/funde_ckgql_din_modlitaotao2018afryxiconsmutasi-bca@l1nyanm1ng/react-picture-viewercthpb-plugin-social@olivervorasai/slidertypes-giscogoportutilsunblock-block-save-variables@infinitebrahmanuniverse/nolb-dom-@saaspe/componentsexpand-react-bridgeopea-bootstraapint_2023_climatemaladiessklif-ui-kitsklif-api@everything-registry/sub-chunk-1500react-native-credit-card-pkgp149-tabletest-popupssklif-ui@wacoco/ytaman-baca-masyarakatwinx-form-winxwholeweb-elements-iconsvue-button-test1vue-loader-open-filewebchewebdesa-laravel-final-releasewebpack_component_fundwxmini-to-vuewxa-cli2-applesf-web-componentssambalsan-loadersass-inline-svgsass-inline-svg-fixresponsis-gantt-task-reactreactofy-css-libraryrn-circular-chartteapackage-tatespoorman297superset-plugin-chart-hello-world2stories-fsstories-react-bdsticky-scroll-catchscx-uisequelcomponentsedanbosokseerbookselect2-selectallrollup-plugin-svg-sprite-loaderreyhan-projecttestapatestujsk_custom_ckeditor5svelte-component-libthistlevite-plugin-md2htmlvue-compmentvite-plugin-vue-static-css-modulesvite-plugin-vitepress-demovite-plugin-vue-css-modulesvc-editorvs-tree-plusnextjs-storiesdfeuk-frontenddfeuk-frontend-manual@panmenghan/http-lib@purnasatria/directus-extension-document-interfacemi-iscrollmeteorproxymmedlf-ui-kitlib-decision-validationless-plugin-inline-svglanj-test-componentshd-html-parserhantil-csshexo-excerptgithongitbook-plugin-plasmagitshugood-spatulajesusdemojeuxuijametimage-carousel-juan-correa-50icons-vue-testinstance-uimailout
1.4.1

3 years ago

1.4.0

3 years ago

2.0.0

3 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

6 years ago

0.1.0

10 years ago

0.0.1

10 years ago

0.0.0

11 years ago