dom-create.js revision 177b40909a5a6eae6736027cdbce3faf45152f81
1127N/A * Creates a new dom node using the provided markup string. 332N/A * @param {String} html The markup used to create the element 332N/A * @param {HTMLDocument} doc An optional document context 332N/A * @return {HTMLElement|DocumentFragment} returns a single HTMLElement 332N/A * when creating one node, and a documentFragment when creating if (
nodes.
length ===
1) {
// return single node, breaking parentNode ref from "fragment" }
else if (
nodes[
0] &&
nodes[
0].
className ===
'yui3-big-dummy') {
// using dummy node to preserve some attributes (e.g. OPTION not selected) }
else {
// return multiple nodes as a fragment if (
nodes.
item) {
// convert live list to static array }
// else inline with log for minification else { Y.
log(
'unable to convert ' +
nodes +
' to fragment',
'warn',
'dom'); }
* Inserts content in a node at the given location * @param {HTMLElement} node The node to insert into * @param {HTMLElement | Array | HTMLCollection} content The content to be inserted * @param {HTMLElement} where Where to insert the content * If no "where" is given, content is appended to the node * Possible values for "where" * <dd>The element to insert before</dd> * <dd>Replaces the existing HTML</dd> * <dd>Inserts before the existing HTML</dd> * <dd>Inserts content before the node</dd> * <dd>Inserts content after the node</dd> }
else if (
typeof content ==
'string' ||
typeof content ==
'number') {
if (
newNode) {
// allow empty content to clear node // IE adds TBODY when creating TABLE elements (which may share this impl) return Y_DOM.
create(
'<select><option class="yui3-big-dummy" selected></option>' +
html +
'</select>',
doc);