Socket
Book a DemoInstallSign in
Socket

fd-insert-before

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fd-insert-before

insert-before a DOM element in a functional way.

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
2
-77.78%
Maintainers
2
Weekly downloads
 
Created
Source

fd-insert-before

Build Status npm version

insert-before DOM element in a functional way.

Installation

npm install fd-insert-before --save

Usage

Let the DOM be like:

<div id="parentElement">
  <span id="childElement">foo bar</span>
</div>```


```js
let insertBefore = require('fd-insert-before');

let sp1 = elem("span","meow")
,sp2 = document.getElementById("childElement")
,parentDiv = sp2.parentNode

insertBefore(parentDiv, sp1, sp2);

selectOne('#parentElement').children[0].innerText; // => 'meow'

API

insert-before :: parent -> newChild -> refChild

A curried function that takes in:

  • parent The parent of the newly inserted node.

  • newChild The node to insert.

  • refChild The node before which newChild is inserted.

Keywords

fp-dom

FAQs

Package last updated on 15 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts