Package Exports
- mutate-dom
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mutate-dom) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mutate-dom
DOM mutator for A/B experiments.
Installation
npm i --save mutate-domUsage example
The HTML to mutate.
<div class="user">
<div class="name">John</div>
<div class="ava-container">
<img src="http://api.randomuser.me/portraits/thumb/men/39.jpg"/>
</div>
</div>The code that mutates the HTML.
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