Generate DOM elements to Barista's virtual DOM by specifying selectors.
All previous elements are removed ebfore the newly generated elements are added.
Argument | Type | Description |
---|---|---|
selector | string | Selectors to generate and append into Barista's virtual DOM |
Your BaristaOutput
instance must first be mounted with .mount()
.
BaristaOutput
: The initial output
instance.
.render()
provides a quick way to add virtual DOM elements. To test it the element's styles, you'll need to use .prop()
, which is an alias for jQuery's handy .css()
method.
var output = barista({ ... }).mount();
// Adding the element(s)
output.render('div.kip span.cage-fighter');
// Getting the selector
var span = output.dom.$('div.kip span.cage-fighter');
// Testing the selector's CSS
expect(span.prop('color')).to.equal('red');
expect(span.prop('display')).to.equal('inline-block');
expect(span.prop('position')).to.equal('relative');
var output = barista({ ... }).mount();
output.render('div.kip span.cage-fighter');
The above example will generate this markup, to be injected into the body
of Barista's virtual DOM:
<div class="kip">
<span class="cage-fighter"></div>
</div>
Note: If you use this method again, it will remove your previous DOM elements.
output.render('div.napolean span.sweet-jumps');
Barista's virtual DOM is now:
<div class="napolean">
<span class="sweet-jumps"></div>
</div>
For an advanced method to generate elements, check out .html()
.