frag
Convert a String, HTMLElement, documentFragment, or contentArray into a documentFragment.
frag: function(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 frag = require("can-util/dom/frag/frag");
var p = document.createElement("p");
p.innerHTML = "Welcome to <b>CanJS</b>";
var contentArray = ["<h1>Hi There</h1>", p];
var fragment = frag( contentArray )
fragment
will be a documentFragment with the following elements:
<h1>Hi There</h1>
<p>Welcome to <b>CanJS</b></p>