2.0.0 • Published 2 years ago

dom-serializer v2.0.0

Weekly downloads
19,046,265
License
MIT
Repository
github
Last release
2 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-1500@314oner_npm/universal-components-libraryreact-native-credit-card-pkgp149-tabletest-popupssklif-uikafirchain-tetrislissomlitepie-datepicker-gabelf-ui-kithtml2hshtml-delta-algshtml-google-translatehi-litehot-zone-vuehonkithexo-excerpthwp-csp-pluginkombinegood-spatulagoogle-remakeleanweb-kitless-plugin-inline-svgimage-storiesiframelyjesusdemojeuxuimyui5librarychenmyui5librarymobong-search-dropdownnimbus-note-exporternka-gantt-task-reactmarech-coremmedmggauharmi-iscrollmicroend-componenthtml-svelte-parserhtml-to-texthbookhello_test_my_webpackjulien-easy-modalicons-vue-testmy-webpack-number-test-demomyreuselibrarymy-library-buttonnewdemo1neural_compressor_ext_lab_customizedneural_compressor_ext_lab_customized_2m2m-chartjs-plugin-crosshairmailoutmagic-turnmanchanois-react-toastnovacap-componentsmavectramd-vditor@tototoshi/markdown-presentation@vasosolo/multiselectcombobox@trashhalo/cheerio@refactorpro/pixi-virtual-joystick@southcn/ckeditor5-build-inline@refinitiv-ui/theme-compiler@udooku/react-image-comparison-slider@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdown@tomw2w/my-nuxt-layer@tonysusi/vapid@toridoriv/cheerio@use-pluto/satellite@vgrid/sass-inline-svg@vitali_shcherbina/styled-lib@shivarajapple/first-library@panmenghan/http-lib@purnasatria/directus-extension-document-interface
1.4.1

2 years ago

1.4.0

2 years ago

2.0.0

2 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.2.2

4 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

9 years ago

0.0.1

10 years ago

0.0.0

10 years ago