Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Convert a string of HTML into a DocumentFragment

License

NotificationsYou must be signed in to change notification settings

kevinokerlund/html-fragment

Repository files navigation

Convert a string of HTML into a DocumentFragment.

Unlike most other utilities, or general methods that return a fragment from an HTML string,this utility will preservenodes that require specific parent tags, such as atd element.

Less than 1k gzipped

Install

npm install --save html-fragment

Usage

In the browser

If the library is directly sourced to the window, it operates on the HtmlFragment global variable:

window.HtmlFragment

In ES6

importHtmlFragmentfrom'html-fragment';

Once you have access to the function, just pass the HTML you want turned into a DocumentFragment into the function.

varfragment=HtmlFragment('<div>Some crazy amount of HTML</div>');

Browser support

ChromeFirefoxSafariIEEdge
9+

About

Convert a string of HTML into a DocumentFragment

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp