Skip to content

hkfoster/vanilla-unorphanize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Vanilla Flavored Unorphanize

Prevent orphans with zero dependencies

Based on https://github.com/simeydotme/jQuery-Unorphanize, this plugin weighs in at ~ 840 bytes minified and works without the need for a JavaScript library.

How it Works

Vanilla Unorphanize will take the supplied selector(s) new unorphanize( 'selector, selector' ); and replace the last space with a   preventing an orphan from occurring. All without disturbing any inner HTML elements.

Basic Usage

// Prevent orphans in all paragraphs
new unorphanize( 'p' );

Custom Usage

// Prevent orphans in all paragraphs w/ 2 companions
new unorphanize( 'p', { companions: 2 } );

Pretty easy, right? Feel free to share, modify, and use this plugin in all your projects. I only ask that you let me know what you build! Thanks.

About

Prevent orphans with zero dependencies

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published