Last active
October 1, 2016 19:55
-
-
Save englishextra/fa19e39ce84982b17fc76485db9d1bea to your computer and use it in GitHub Desktop.
Adds Element BEFORE NeighborElement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* Adds Element as fragment BEFORE NeighborElement | |
* gist.github.com/englishextra/fa19e39ce84982b17fc76485db9d1bea | |
* @param {String|object} e HTML Element to prepend before before | |
* @param {Object} a target HTML Element | |
* prependFragmentBefore(e,a) | |
*/ | |
var prependFragmentBefore=function(e,a){"string"===typeof e&&(e=document.createTextNode(e));var p=a.parentNode||"",df=document.createDocumentFragment();p&&df.appendChild(e)&&p.insertBefore(df,a);return!1;}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment