Skip to content

fp-dom/fd-replace

Repository files navigation

fd-replace

Build Status npm version

replace DOM element in a functional way.

Installation

npm install fd-replace --save

Usage

import elem from 'fd-elem';
import append from 'fd-append';
import replace from 'replace';

let appendtoBody = append(document.body),
h1 = elem('h1','meow'),
h2 = elem('h2', 'bow');

appendtoBody(h1);
  
replace(document.body,h2,h1);

assert.equal(document.body.lastChild.textContent, 'bow'); // True.

API

append :: parent -> oldNode -> newNode

A curried function that takes in:

  • parent -> Parent element in which the DOM must be replaced.

  • oldNode -> DOM element that is to be replaced.

  • newNode -> New DOM element.

About

replace DOM element in a functional way.

Resources

License

Stars

Watchers

Forks

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy