can-fragment
Convert a String, HTMLElement, documentFragment, contentArray, or object with a can.toDOM
symbol into a documentFragment.
fragment(item, doc)
Parameters
- item
{String|HTMLElement|documentFragment|contentArray}
: - doc
{Document}
:an optional DOM document in which to build the fragment
Returns
{documentFragment}
:
Use
ContentArrays can be used to combine multiple HTMLElements into a single document fragment. For example:
var fragment = require("can-fragment");
var p = document.createElement("p");
p.innerHTML = "Welcome to <b>CanJS</b>";
var contentArray = ["<h1>Hi There</h1>", p];
var fragment = fragment( contentArray )
fragment
will be a documentFragment with the following elements:
<h1>Hi There</h1>
<p>Welcome to <b>CanJS</b></p>