Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zkochan/mutate-dom
DOM mutator for A/B experiments.
https://github.com/zkochan/mutate-dom
Last synced: 29 days ago
JSON representation
DOM mutator for A/B experiments.
- Host: GitHub
- URL: https://github.com/zkochan/mutate-dom
- Owner: zkochan
- License: mit
- Created: 2015-08-21T17:36:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-25T19:51:48.000Z (about 8 years ago)
- Last Synced: 2024-11-25T08:41:11.283Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mutate-dom
DOM mutator for A/B experiments.
[![Dependency Status](https://david-dm.org/zkochan/mutate-dom/status.svg?style=flat)](https://david-dm.org/zkochan/mutate-dom)
[![Build Status](https://travis-ci.org/zkochan/mutate-dom.svg?branch=master)](https://travis-ci.org/zkochan/mutate-dom)
[![npm version](https://badge.fury.io/js/mutate-dom.svg)](http://badge.fury.io/js/mutate-dom)# Installation
```
npm i --save mutate-dom
```## Usage example
The HTML to mutate.
```html
John
```The code that mutates the HTML.
```js
var mu = require('mutate-dom');
var mutator = require('mutate-dom').mutator;mu.addClass = mutator(function(el, newClass) {
$(el).addClass(newClass);
});mu.src = mutator(function(el, src) {
$(el).attr('src', src);
});mu({
'.user': {
'.name': 'Bill',
'.hobbies': mu.slice(0, 1, 'football'),
'.ava-container': [{
img: mu.src('http://api.randomuser.me/portraits/thumb/men/59.jpg')
},
mu.addClass('awesome-ava-container')
]
}
});
```## License
MIT © [Zoltan Kochan](https://www.kochan.io)