PageRenderTime 29ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/ajax/libs/yui/3.9.1/dom-base/dom-base-coverage.js

https://gitlab.com/Mirros/cdnjs
JavaScript | 676 lines | 502 code | 69 blank | 105 comment | 93 complexity | 0b050ba3f91407a644d9fa7a95f4a117 MD5 | raw file
  1. if (typeof _yuitest_coverage == "undefined"){
  2. _yuitest_coverage = {};
  3. _yuitest_coverline = function(src, line){
  4. var coverage = _yuitest_coverage[src];
  5. if (!coverage.lines[line]){
  6. coverage.calledLines++;
  7. }
  8. coverage.lines[line]++;
  9. };
  10. _yuitest_coverfunc = function(src, name, line){
  11. var coverage = _yuitest_coverage[src],
  12. funcId = name + ":" + line;
  13. if (!coverage.functions[funcId]){
  14. coverage.calledFunctions++;
  15. }
  16. coverage.functions[funcId]++;
  17. };
  18. }
  19. _yuitest_coverage["build/dom-base/dom-base.js"] = {
  20. lines: {},
  21. functions: {},
  22. coveredLines: 0,
  23. calledLines: 0,
  24. coveredFunctions: 0,
  25. calledFunctions: 0,
  26. path: "build/dom-base/dom-base.js",
  27. code: []
  28. };
  29. _yuitest_coverage["build/dom-base/dom-base.js"].code=["YUI.add('dom-base', function (Y, NAME) {","","/**","* @for DOM","* @module dom","*/","var documentElement = Y.config.doc.documentElement,"," Y_DOM = Y.DOM,"," TAG_NAME = 'tagName',"," OWNER_DOCUMENT = 'ownerDocument',"," EMPTY_STRING = '',"," addFeature = Y.Features.add,"," testFeature = Y.Features.test;","","Y.mix(Y_DOM, {"," /**"," * Returns the text content of the HTMLElement. "," * @method getText "," * @param {HTMLElement} element The html element. "," * @return {String} The text content of the element (includes text of any descending elements)."," */"," getText: (documentElement.textContent !== undefined) ?"," function(element) {"," var ret = '';"," if (element) {"," ret = element.textContent;"," }"," return ret || '';"," } : function(element) {"," var ret = '';"," if (element) {"," ret = element.innerText || element.nodeValue; // might be a textNode"," }"," return ret || '';"," },",""," /**"," * Sets the text content of the HTMLElement. "," * @method setText "," * @param {HTMLElement} element The html element. "," * @param {String} content The content to add. "," */"," setText: (documentElement.textContent !== undefined) ?"," function(element, content) {"," if (element) {"," element.textContent = content;"," }"," } : function(element, content) {"," if ('innerText' in element) {"," element.innerText = content;"," } else if ('nodeValue' in element) {"," element.nodeValue = content;"," }"," },",""," CUSTOM_ATTRIBUTES: (!documentElement.hasAttribute) ? { // IE < 8"," 'for': 'htmlFor',"," 'class': 'className'"," } : { // w3c"," 'htmlFor': 'for',"," 'className': 'class'"," },",""," /**"," * Provides a normalized attribute interface. "," * @method setAttribute"," * @param {HTMLElement} el The target element for the attribute."," * @param {String} attr The attribute to set."," * @param {String} val The value of the attribute."," */"," setAttribute: function(el, attr, val, ieAttr) {"," if (el && attr && el.setAttribute) {"," attr = Y_DOM.CUSTOM_ATTRIBUTES[attr] || attr;"," el.setAttribute(attr, val, ieAttr);"," }"," },","",""," /**"," * Provides a normalized attribute interface. "," * @method getAttribute"," * @param {HTMLElement} el The target element for the attribute."," * @param {String} attr The attribute to get."," * @return {String} The current value of the attribute. "," */"," getAttribute: function(el, attr, ieAttr) {"," ieAttr = (ieAttr !== undefined) ? ieAttr : 2;"," var ret = '';"," if (el && attr && el.getAttribute) {"," attr = Y_DOM.CUSTOM_ATTRIBUTES[attr] || attr;"," ret = el.getAttribute(attr, ieAttr);",""," if (ret === null) {"," ret = ''; // per DOM spec"," }"," }"," return ret;"," },",""," VALUE_SETTERS: {},",""," VALUE_GETTERS: {},",""," getValue: function(node) {"," var ret = '', // TODO: return null?"," getter;",""," if (node && node[TAG_NAME]) {"," getter = Y_DOM.VALUE_GETTERS[node[TAG_NAME].toLowerCase()];",""," if (getter) {"," ret = getter(node);"," } else {"," ret = node.value;"," }"," }",""," // workaround for IE8 JSON stringify bug"," // which converts empty string values to null"," if (ret === EMPTY_STRING) {"," ret = EMPTY_STRING; // for real"," }",""," return (typeof ret === 'string') ? ret : '';"," },",""," setValue: function(node, val) {"," var setter;",""," if (node && node[TAG_NAME]) {"," setter = Y_DOM.VALUE_SETTERS[node[TAG_NAME].toLowerCase()];",""," if (setter) {"," setter(node, val);"," } else {"," node.value = val;"," }"," }"," },",""," creators: {}","});","","addFeature('value-set', 'select', {"," test: function() {"," var node = Y.config.doc.createElement('select');"," node.innerHTML = '<option>1</option><option>2</option>';"," node.value = '2';"," return (node.value && node.value === '2');"," }","});","","if (!testFeature('value-set', 'select')) {"," Y_DOM.VALUE_SETTERS.select = function(node, val) {"," for (var i = 0, options = node.getElementsByTagName('option'), option;"," option = options[i++];) {"," if (Y_DOM.getValue(option) === val) {"," option.selected = true;"," //Y_DOM.setAttribute(option, 'selected', 'selected');"," break;"," }"," }"," };","}","","Y.mix(Y_DOM.VALUE_GETTERS, {"," button: function(node) {"," return (node.attributes && node.attributes.value) ? node.attributes.value.value : '';"," }","});","","Y.mix(Y_DOM.VALUE_SETTERS, {"," // IE: node.value changes the button text, which should be handled via innerHTML"," button: function(node, val) {"," var attr = node.attributes.value;"," if (!attr) {"," attr = node[OWNER_DOCUMENT].createAttribute('value');"," node.setAttributeNode(attr);"," }",""," attr.value = val;"," }","});","","","Y.mix(Y_DOM.VALUE_GETTERS, {"," option: function(node) {"," var attrs = node.attributes;"," return (attrs.value && attrs.value.specified) ? node.value : node.text;"," },",""," select: function(node) {"," var val = node.value,"," options = node.options;",""," if (options && options.length) {"," // TODO: implement multipe select"," if (node.multiple) {"," } else if (node.selectedIndex > -1) {"," val = Y_DOM.getValue(options[node.selectedIndex]);"," }"," }",""," return val;"," }","});","var addClass, hasClass, removeClass;","","Y.mix(Y.DOM, {"," /**"," * Determines whether a DOM element has the given className."," * @method hasClass"," * @for DOM"," * @param {HTMLElement} element The DOM element. "," * @param {String} className the class name to search for"," * @return {Boolean} Whether or not the element has the given class. "," */"," hasClass: function(node, className) {"," var re = Y.DOM._getRegExp('(?:^|\\\\s+)' + className + '(?:\\\\s+|$)');"," return re.test(node.className);"," },",""," /**"," * Adds a class name to a given DOM element."," * @method addClass "," * @for DOM"," * @param {HTMLElement} element The DOM element. "," * @param {String} className the class name to add to the class attribute"," */"," addClass: function(node, className) {"," if (!Y.DOM.hasClass(node, className)) { // skip if already present "," node.className = Y.Lang.trim([node.className, className].join(' '));"," }"," },",""," /**"," * Removes a class name from a given element."," * @method removeClass "," * @for DOM"," * @param {HTMLElement} element The DOM element. "," * @param {String} className the class name to remove from the class attribute"," */"," removeClass: function(node, className) {"," if (className && hasClass(node, className)) {"," node.className = Y.Lang.trim(node.className.replace(Y.DOM._getRegExp('(?:^|\\\\s+)' +"," className + '(?:\\\\s+|$)'), ' '));",""," if ( hasClass(node, className) ) { // in case of multiple adjacent"," removeClass(node, className);"," }"," } "," },",""," /**"," * Replace a class with another class for a given element."," * If no oldClassName is present, the newClassName is simply added."," * @method replaceClass "," * @for DOM"," * @param {HTMLElement} element The DOM element "," * @param {String} oldClassName the class name to be replaced"," * @param {String} newClassName the class name that will be replacing the old class name"," */"," replaceClass: function(node, oldC, newC) {"," removeClass(node, oldC); // remove first in case oldC === newC"," addClass(node, newC);"," },",""," /**"," * If the className exists on the node it is removed, if it doesn't exist it is added."," * @method toggleClass "," * @for DOM"," * @param {HTMLElement} element The DOM element"," * @param {String} className the class name to be toggled"," * @param {Boolean} addClass optional boolean to indicate whether class"," * should be added or removed regardless of current state"," */"," toggleClass: function(node, className, force) {"," var add = (force !== undefined) ? force :"," !(hasClass(node, className));",""," if (add) {"," addClass(node, className);"," } else {"," removeClass(node, className);"," }"," }","});","","hasClass = Y.DOM.hasClass;","removeClass = Y.DOM.removeClass;","addClass = Y.DOM.addClass;","","var re_tag = /<([a-z]+)/i,",""," Y_DOM = Y.DOM,",""," addFeature = Y.Features.add,"," testFeature = Y.Features.test,",""," creators = {},",""," createFromDIV = function(html, tag) {"," var div = Y.config.doc.createElement('div'),"," ret = true;",""," div.innerHTML = html;"," if (!div.firstChild || div.firstChild.tagName !== tag.toUpperCase()) {"," ret = false;"," }",""," return ret;"," },",""," re_tbody = /(?:\\/(?:thead|tfoot|tbody|caption|col|colgroup)>)+\\s*<tbody/,",""," TABLE_OPEN = '<table>',"," TABLE_CLOSE = '</table>';","","Y.mix(Y.DOM, {"," _fragClones: {},",""," _create: function(html, doc, tag) {"," tag = tag || 'div';",""," var frag = Y_DOM._fragClones[tag];"," if (frag) {"," frag = frag.cloneNode(false);"," } else {"," frag = Y_DOM._fragClones[tag] = doc.createElement(tag);"," }"," frag.innerHTML = html;"," return frag;"," },",""," _children: function(node, tag) {"," var i = 0,"," children = node.children,"," childNodes,"," hasComments,"," child;",""," if (children && children.tags) { // use tags filter when possible"," if (tag) {"," children = node.children.tags(tag);"," } else { // IE leaks comments into children"," hasComments = children.tags('!').length;"," }"," }"," "," if (!children || (!children.tags && tag) || hasComments) {"," childNodes = children || node.childNodes;"," children = [];"," while ((child = childNodes[i++])) {"," if (child.nodeType === 1) {"," if (!tag || tag === child.tagName) {"," children.push(child);"," }"," }"," }"," }",""," return children || [];"," },",""," /**"," * Creates a new dom node using the provided markup string. "," * @method create"," * @param {String} html The markup used to create the element"," * @param {HTMLDocument} doc An optional document context "," * @return {HTMLElement|DocumentFragment} returns a single HTMLElement "," * when creating one node, and a documentFragment when creating"," * multiple nodes."," */"," create: function(html, doc) {"," if (typeof html === 'string') {"," html = Y.Lang.trim(html); // match IE which trims whitespace from innerHTML",""," }",""," doc = doc || Y.config.doc;"," var m = re_tag.exec(html),"," create = Y_DOM._create,"," custom = creators,"," ret = null,"," creator,"," tag, nodes;",""," if (html != undefined) { // not undefined or null"," if (m && m[1]) {"," creator = custom[m[1].toLowerCase()];"," if (typeof creator === 'function') {"," create = creator; "," } else {"," tag = creator;"," }"," }",""," nodes = create(html, doc, tag).childNodes;",""," if (nodes.length === 1) { // return single node, breaking parentNode ref from \"fragment\""," ret = nodes[0].parentNode.removeChild(nodes[0]);"," } else if (nodes[0] && nodes[0].className === 'yui3-big-dummy') { // using dummy node to preserve some attributes (e.g. OPTION not selected)"," if (nodes.length === 2) {"," ret = nodes[0].nextSibling;"," } else {"," nodes[0].parentNode.removeChild(nodes[0]); "," ret = Y_DOM._nl2frag(nodes, doc);"," }"," } else { // return multiple nodes as a fragment"," ret = Y_DOM._nl2frag(nodes, doc);"," }",""," }",""," return ret;"," },",""," _nl2frag: function(nodes, doc) {"," var ret = null,"," i, len;",""," if (nodes && (nodes.push || nodes.item) && nodes[0]) {"," doc = doc || nodes[0].ownerDocument; "," ret = doc.createDocumentFragment();",""," if (nodes.item) { // convert live list to static array"," nodes = Y.Array(nodes, 0, true);"," }",""," for (i = 0, len = nodes.length; i < len; i++) {"," ret.appendChild(nodes[i]); "," }"," } // else inline with log for minification"," return ret;"," },",""," /**"," * Inserts content in a node at the given location "," * @method addHTML"," * @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\""," * <dl>"," * <dt>HTMLElement</dt>"," * <dd>The element to insert before</dd>"," * <dt>\"replace\"</dt>"," * <dd>Replaces the existing HTML</dd>"," * <dt>\"before\"</dt>"," * <dd>Inserts before the existing HTML</dd>"," * <dt>\"before\"</dt>"," * <dd>Inserts content before the node</dd>"," * <dt>\"after\"</dt>"," * <dd>Inserts content after the node</dd>"," * </dl>"," */"," addHTML: function(node, content, where) {"," var nodeParent = node.parentNode,"," i = 0,"," item,"," ret = content,"," newNode;"," ",""," if (content != undefined) { // not null or undefined (maybe 0)"," if (content.nodeType) { // DOM node, just add it"," newNode = content;"," } else if (typeof content == 'string' || typeof content == 'number') {"," ret = newNode = Y_DOM.create(content);"," } else if (content[0] && content[0].nodeType) { // array or collection "," newNode = Y.config.doc.createDocumentFragment();"," while ((item = content[i++])) {"," newNode.appendChild(item); // append to fragment for insertion"," }"," }"," }",""," if (where) {"," if (newNode && where.parentNode) { // insert regardless of relationship to node"," where.parentNode.insertBefore(newNode, where);"," } else {"," switch (where) {"," case 'replace':"," while (node.firstChild) {"," node.removeChild(node.firstChild);"," }"," if (newNode) { // allow empty content to clear node"," node.appendChild(newNode);"," }"," break;"," case 'before':"," if (newNode) {"," nodeParent.insertBefore(newNode, node);"," }"," break;"," case 'after':"," if (newNode) {"," if (node.nextSibling) { // IE errors if refNode is null"," nodeParent.insertBefore(newNode, node.nextSibling);"," } else {"," nodeParent.appendChild(newNode);"," }"," }"," break;"," default:"," if (newNode) {"," node.appendChild(newNode);"," }"," }"," }"," } else if (newNode) {"," node.appendChild(newNode);"," }",""," return ret;"," },",""," wrap: function(node, html) {"," var parent = (html && html.nodeType) ? html : Y.DOM.create(html),"," nodes = parent.getElementsByTagName('*');",""," if (nodes.length) {"," parent = nodes[nodes.length - 1];"," }",""," if (node.parentNode) { "," node.parentNode.replaceChild(parent, node);"," }"," parent.appendChild(node);"," },",""," unwrap: function(node) {"," var parent = node.parentNode,"," lastChild = parent.lastChild,"," next = node,"," grandparent;",""," if (parent) {"," grandparent = parent.parentNode;"," if (grandparent) {"," node = parent.firstChild;"," while (node !== lastChild) {"," next = node.nextSibling;"," grandparent.insertBefore(node, parent);"," node = next;"," }"," grandparent.replaceChild(lastChild, parent);"," } else {"," parent.removeChild(node);"," }"," }"," }","});","","addFeature('innerhtml', 'table', {"," test: function() {"," var node = Y.config.doc.createElement('table');"," try {"," node.innerHTML = '<tbody></tbody>';"," } catch(e) {"," return false;"," }"," return (node.firstChild && node.firstChild.nodeName === 'TBODY');"," }","});","","addFeature('innerhtml-div', 'tr', {"," test: function() {"," return createFromDIV('<tr></tr>', 'tr');"," }","});","","addFeature('innerhtml-div', 'script', {"," test: function() {"," return createFromDIV('<script></script>', 'script');"," }","});","","if (!testFeature('innerhtml', 'table')) {"," // TODO: thead/tfoot with nested tbody"," // IE adds TBODY when creating TABLE elements (which may share this impl)"," creators.tbody = function(html, doc) {"," var frag = Y_DOM.create(TABLE_OPEN + html + TABLE_CLOSE, doc),"," tb = Y.DOM._children(frag, 'tbody')[0];",""," if (frag.children.length > 1 && tb && !re_tbody.test(html)) {"," tb.parentNode.removeChild(tb); // strip extraneous tbody"," }"," return frag;"," };","}","","if (!testFeature('innerhtml-div', 'script')) {"," creators.script = function(html, doc) {"," var frag = doc.createElement('div');",""," frag.innerHTML = '-' + html;"," frag.removeChild(frag.firstChild);"," return frag;"," };",""," creators.link = creators.style = creators.script;","}","","if (!testFeature('innerhtml-div', 'tr')) {"," Y.mix(creators, {"," option: function(html, doc) {"," return Y_DOM.create('<select><option class=\"yui3-big-dummy\" selected></option>' + html + '</select>', doc);"," },",""," tr: function(html, doc) {"," return Y_DOM.create('<tbody>' + html + '</tbody>', doc);"," },",""," td: function(html, doc) {"," return Y_DOM.create('<tr>' + html + '</tr>', doc);"," }, ",""," col: function(html, doc) {"," return Y_DOM.create('<colgroup>' + html + '</colgroup>', doc);"," }, ",""," tbody: 'table'"," });",""," Y.mix(creators, {"," legend: 'fieldset',"," th: creators.td,"," thead: creators.tbody,"," tfoot: creators.tbody,"," caption: creators.tbody,"," colgroup: creators.tbody,"," optgroup: creators.option"," });","}","","Y_DOM.creators = creators;","Y.mix(Y.DOM, {"," /**"," * Sets the width of the element to the given size, regardless"," * of box model, border, padding, etc."," * @method setWidth"," * @param {HTMLElement} element The DOM element. "," * @param {String|Number} size The pixel height to size to"," */",""," setWidth: function(node, size) {"," Y.DOM._setSize(node, 'width', size);"," },",""," /**"," * Sets the height of the element to the given size, regardless"," * of box model, border, padding, etc."," * @method setHeight"," * @param {HTMLElement} element The DOM element. "," * @param {String|Number} size The pixel height to size to"," */",""," setHeight: function(node, size) {"," Y.DOM._setSize(node, 'height', size);"," },",""," _setSize: function(node, prop, val) {"," val = (val > 0) ? val : 0;"," var size = 0;",""," node.style[prop] = val + 'px';"," size = (prop === 'height') ? node.offsetHeight : node.offsetWidth;",""," if (size > val) {"," val = val - (size - val);",""," if (val < 0) {"," val = 0;"," }",""," node.style[prop] = val + 'px';"," }"," }","});","","","}, '@VERSION@', {\"requires\": [\"dom-core\"]});"];
  30. _yuitest_coverage["build/dom-base/dom-base.js"].lines = {"1":0,"7":0,"15":0,"24":0,"25":0,"26":0,"28":0,"30":0,"31":0,"32":0,"34":0,"45":0,"46":0,"49":0,"50":0,"51":0,"52":0,"72":0,"73":0,"74":0,"87":0,"88":0,"89":0,"90":0,"91":0,"93":0,"94":0,"97":0,"105":0,"108":0,"109":0,"111":0,"112":0,"114":0,"120":0,"121":0,"124":0,"128":0,"130":0,"131":0,"133":0,"134":0,"136":0,"144":0,"146":0,"147":0,"148":0,"149":0,"153":0,"154":0,"155":0,"157":0,"158":0,"160":0,"166":0,"168":0,"172":0,"175":0,"176":0,"177":0,"178":0,"181":0,"186":0,"188":0,"189":0,"193":0,"196":0,"198":0,"199":0,"200":0,"204":0,"207":0,"209":0,"219":0,"220":0,"231":0,"232":0,"244":0,"245":0,"248":0,"249":0,"264":0,"265":0,"278":0,"281":0,"282":0,"284":0,"289":0,"290":0,"291":0,"293":0,"303":0,"306":0,"307":0,"308":0,"311":0,"319":0,"323":0,"325":0,"326":0,"327":0,"329":0,"331":0,"332":0,"336":0,"342":0,"343":0,"344":0,"346":0,"350":0,"351":0,"352":0,"353":0,"354":0,"355":0,"356":0,"362":0,"375":0,"376":0,"380":0,"381":0,"388":0,"389":0,"390":0,"391":0,"392":0,"394":0,"398":0,"400":0,"401":0,"402":0,"403":0,"404":0,"406":0,"407":0,"410":0,"415":0,"419":0,"422":0,"423":0,"424":0,"426":0,"427":0,"430":0,"431":0,"434":0,"459":0,"466":0,"467":0,"468":0,"469":0,"470":0,"471":0,"472":0,"473":0,"474":0,"479":0,"480":0,"481":0,"483":0,"485":0,"486":0,"488":0,"489":0,"491":0,"493":0,"494":0,"496":0,"498":0,"499":0,"500":0,"502":0,"505":0,"507":0,"508":0,"512":0,"513":0,"516":0,"520":0,"523":0,"524":0,"527":0,"528":0,"530":0,"534":0,"539":0,"540":0,"541":0,"542":0,"543":0,"544":0,"545":0,"546":0,"548":0,"550":0,"556":0,"558":0,"559":0,"560":0,"562":0,"564":0,"568":0,"570":0,"574":0,"576":0,"580":0,"583":0,"584":0,"587":0,"588":0,"590":0,"594":0,"595":0,"596":0,"598":0,"599":0,"600":0,"603":0,"606":0,"607":0,"609":0,"613":0,"617":0,"621":0,"627":0,"638":0,"639":0,"649":0,"661":0,"665":0,"666":0,"668":0,"669":0,"671":0,"672":0,"674":0,"675":0,"678":0};
  31. _yuitest_coverage["build/dom-base/dom-base.js"].functions = {"(anonymous 2):23":0,"}:29":0,"(anonymous 3):44":0,"}:48":0,"setAttribute:71":0,"getAttribute:86":0,"getValue:104":0,"setValue:127":0,"test:145":0,"select:154":0,"button:167":0,"button:174":0,"option:187":0,"select:192":0,"hasClass:218":0,"addClass:230":0,"removeClass:243":0,"replaceClass:263":0,"toggleClass:277":0,"createFromDIV:302":0,"_create:322":0,"_children:335":0,"create:374":0,"_nl2frag:418":0,"addHTML:458":0,"wrap:519":0,"unwrap:533":0,"test:557":0,"test:569":0,"test:575":0,"tbody:583":0,"script:595":0,"option:608":0,"tr:612":0,"td:616":0,"col:620":0,"setWidth:648":0,"setHeight:660":0,"_setSize:664":0,"(anonymous 1):1":0};
  32. _yuitest_coverage["build/dom-base/dom-base.js"].coveredLines = 238;
  33. _yuitest_coverage["build/dom-base/dom-base.js"].coveredFunctions = 40;
  34. _yuitest_coverline("build/dom-base/dom-base.js", 1);
  35. YUI.add('dom-base', function (Y, NAME) {
  36. /**
  37. * @for DOM
  38. * @module dom
  39. */
  40. _yuitest_coverfunc("build/dom-base/dom-base.js", "(anonymous 1)", 1);
  41. _yuitest_coverline("build/dom-base/dom-base.js", 7);
  42. var documentElement = Y.config.doc.documentElement,
  43. Y_DOM = Y.DOM,
  44. TAG_NAME = 'tagName',
  45. OWNER_DOCUMENT = 'ownerDocument',
  46. EMPTY_STRING = '',
  47. addFeature = Y.Features.add,
  48. testFeature = Y.Features.test;
  49. _yuitest_coverline("build/dom-base/dom-base.js", 15);
  50. Y.mix(Y_DOM, {
  51. /**
  52. * Returns the text content of the HTMLElement.
  53. * @method getText
  54. * @param {HTMLElement} element The html element.
  55. * @return {String} The text content of the element (includes text of any descending elements).
  56. */
  57. getText: (documentElement.textContent !== undefined) ?
  58. function(element) {
  59. _yuitest_coverfunc("build/dom-base/dom-base.js", "(anonymous 2)", 23);
  60. _yuitest_coverline("build/dom-base/dom-base.js", 24);
  61. var ret = '';
  62. _yuitest_coverline("build/dom-base/dom-base.js", 25);
  63. if (element) {
  64. _yuitest_coverline("build/dom-base/dom-base.js", 26);
  65. ret = element.textContent;
  66. }
  67. _yuitest_coverline("build/dom-base/dom-base.js", 28);
  68. return ret || '';
  69. } : function(element) {
  70. _yuitest_coverfunc("build/dom-base/dom-base.js", "}", 29);
  71. _yuitest_coverline("build/dom-base/dom-base.js", 30);
  72. var ret = '';
  73. _yuitest_coverline("build/dom-base/dom-base.js", 31);
  74. if (element) {
  75. _yuitest_coverline("build/dom-base/dom-base.js", 32);
  76. ret = element.innerText || element.nodeValue; // might be a textNode
  77. }
  78. _yuitest_coverline("build/dom-base/dom-base.js", 34);
  79. return ret || '';
  80. },
  81. /**
  82. * Sets the text content of the HTMLElement.
  83. * @method setText
  84. * @param {HTMLElement} element The html element.
  85. * @param {String} content The content to add.
  86. */
  87. setText: (documentElement.textContent !== undefined) ?
  88. function(element, content) {
  89. _yuitest_coverfunc("build/dom-base/dom-base.js", "(anonymous 3)", 44);
  90. _yuitest_coverline("build/dom-base/dom-base.js", 45);
  91. if (element) {
  92. _yuitest_coverline("build/dom-base/dom-base.js", 46);
  93. element.textContent = content;
  94. }
  95. } : function(element, content) {
  96. _yuitest_coverfunc("build/dom-base/dom-base.js", "}", 48);
  97. _yuitest_coverline("build/dom-base/dom-base.js", 49);
  98. if ('innerText' in element) {
  99. _yuitest_coverline("build/dom-base/dom-base.js", 50);
  100. element.innerText = content;
  101. } else {_yuitest_coverline("build/dom-base/dom-base.js", 51);
  102. if ('nodeValue' in element) {
  103. _yuitest_coverline("build/dom-base/dom-base.js", 52);
  104. element.nodeValue = content;
  105. }}
  106. },
  107. CUSTOM_ATTRIBUTES: (!documentElement.hasAttribute) ? { // IE < 8
  108. 'for': 'htmlFor',
  109. 'class': 'className'
  110. } : { // w3c
  111. 'htmlFor': 'for',
  112. 'className': 'class'
  113. },
  114. /**
  115. * Provides a normalized attribute interface.
  116. * @method setAttribute
  117. * @param {HTMLElement} el The target element for the attribute.
  118. * @param {String} attr The attribute to set.
  119. * @param {String} val The value of the attribute.
  120. */
  121. setAttribute: function(el, attr, val, ieAttr) {
  122. _yuitest_coverfunc("build/dom-base/dom-base.js", "setAttribute", 71);
  123. _yuitest_coverline("build/dom-base/dom-base.js", 72);
  124. if (el && attr && el.setAttribute) {
  125. _yuitest_coverline("build/dom-base/dom-base.js", 73);
  126. attr = Y_DOM.CUSTOM_ATTRIBUTES[attr] || attr;
  127. _yuitest_coverline("build/dom-base/dom-base.js", 74);
  128. el.setAttribute(attr, val, ieAttr);
  129. }
  130. },
  131. /**
  132. * Provides a normalized attribute interface.
  133. * @method getAttribute
  134. * @param {HTMLElement} el The target element for the attribute.
  135. * @param {String} attr The attribute to get.
  136. * @return {String} The current value of the attribute.
  137. */
  138. getAttribute: function(el, attr, ieAttr) {
  139. _yuitest_coverfunc("build/dom-base/dom-base.js", "getAttribute", 86);
  140. _yuitest_coverline("build/dom-base/dom-base.js", 87);
  141. ieAttr = (ieAttr !== undefined) ? ieAttr : 2;
  142. _yuitest_coverline("build/dom-base/dom-base.js", 88);
  143. var ret = '';
  144. _yuitest_coverline("build/dom-base/dom-base.js", 89);
  145. if (el && attr && el.getAttribute) {
  146. _yuitest_coverline("build/dom-base/dom-base.js", 90);
  147. attr = Y_DOM.CUSTOM_ATTRIBUTES[attr] || attr;
  148. _yuitest_coverline("build/dom-base/dom-base.js", 91);
  149. ret = el.getAttribute(attr, ieAttr);
  150. _yuitest_coverline("build/dom-base/dom-base.js", 93);
  151. if (ret === null) {
  152. _yuitest_coverline("build/dom-base/dom-base.js", 94);
  153. ret = ''; // per DOM spec
  154. }
  155. }
  156. _yuitest_coverline("build/dom-base/dom-base.js", 97);
  157. return ret;
  158. },
  159. VALUE_SETTERS: {},
  160. VALUE_GETTERS: {},
  161. getValue: function(node) {
  162. _yuitest_coverfunc("build/dom-base/dom-base.js", "getValue", 104);
  163. _yuitest_coverline("build/dom-base/dom-base.js", 105);
  164. var ret = '', // TODO: return null?
  165. getter;
  166. _yuitest_coverline("build/dom-base/dom-base.js", 108);
  167. if (node && node[TAG_NAME]) {
  168. _yuitest_coverline("build/dom-base/dom-base.js", 109);
  169. getter = Y_DOM.VALUE_GETTERS[node[TAG_NAME].toLowerCase()];
  170. _yuitest_coverline("build/dom-base/dom-base.js", 111);
  171. if (getter) {
  172. _yuitest_coverline("build/dom-base/dom-base.js", 112);
  173. ret = getter(node);
  174. } else {
  175. _yuitest_coverline("build/dom-base/dom-base.js", 114);
  176. ret = node.value;
  177. }
  178. }
  179. // workaround for IE8 JSON stringify bug
  180. // which converts empty string values to null
  181. _yuitest_coverline("build/dom-base/dom-base.js", 120);
  182. if (ret === EMPTY_STRING) {
  183. _yuitest_coverline("build/dom-base/dom-base.js", 121);
  184. ret = EMPTY_STRING; // for real
  185. }
  186. _yuitest_coverline("build/dom-base/dom-base.js", 124);
  187. return (typeof ret === 'string') ? ret : '';
  188. },
  189. setValue: function(node, val) {
  190. _yuitest_coverfunc("build/dom-base/dom-base.js", "setValue", 127);
  191. _yuitest_coverline("build/dom-base/dom-base.js", 128);
  192. var setter;
  193. _yuitest_coverline("build/dom-base/dom-base.js", 130);
  194. if (node && node[TAG_NAME]) {
  195. _yuitest_coverline("build/dom-base/dom-base.js", 131);
  196. setter = Y_DOM.VALUE_SETTERS[node[TAG_NAME].toLowerCase()];
  197. _yuitest_coverline("build/dom-base/dom-base.js", 133);
  198. if (setter) {
  199. _yuitest_coverline("build/dom-base/dom-base.js", 134);
  200. setter(node, val);
  201. } else {
  202. _yuitest_coverline("build/dom-base/dom-base.js", 136);
  203. node.value = val;
  204. }
  205. }
  206. },
  207. creators: {}
  208. });
  209. _yuitest_coverline("build/dom-base/dom-base.js", 144);
  210. addFeature('value-set', 'select', {
  211. test: function() {
  212. _yuitest_coverfunc("build/dom-base/dom-base.js", "test", 145);
  213. _yuitest_coverline("build/dom-base/dom-base.js", 146);
  214. var node = Y.config.doc.createElement('select');
  215. _yuitest_coverline("build/dom-base/dom-base.js", 147);
  216. node.innerHTML = '<option>1</option><option>2</option>';
  217. _yuitest_coverline("build/dom-base/dom-base.js", 148);
  218. node.value = '2';
  219. _yuitest_coverline("build/dom-base/dom-base.js", 149);
  220. return (node.value && node.value === '2');
  221. }
  222. });
  223. _yuitest_coverline("build/dom-base/dom-base.js", 153);
  224. if (!testFeature('value-set', 'select')) {
  225. _yuitest_coverline("build/dom-base/dom-base.js", 154);
  226. Y_DOM.VALUE_SETTERS.select = function(node, val) {
  227. _yuitest_coverfunc("build/dom-base/dom-base.js", "select", 154);
  228. _yuitest_coverline("build/dom-base/dom-base.js", 155);
  229. for (var i = 0, options = node.getElementsByTagName('option'), option;
  230. option = options[i++];) {
  231. _yuitest_coverline("build/dom-base/dom-base.js", 157);
  232. if (Y_DOM.getValue(option) === val) {
  233. _yuitest_coverline("build/dom-base/dom-base.js", 158);
  234. option.selected = true;
  235. //Y_DOM.setAttribute(option, 'selected', 'selected');
  236. _yuitest_coverline("build/dom-base/dom-base.js", 160);
  237. break;
  238. }
  239. }
  240. };
  241. }
  242. _yuitest_coverline("build/dom-base/dom-base.js", 166);
  243. Y.mix(Y_DOM.VALUE_GETTERS, {
  244. button: function(node) {
  245. _yuitest_coverfunc("build/dom-base/dom-base.js", "button", 167);
  246. _yuitest_coverline("build/dom-base/dom-base.js", 168);
  247. return (node.attributes && node.attributes.value) ? node.attributes.value.value : '';
  248. }
  249. });
  250. _yuitest_coverline("build/dom-base/dom-base.js", 172);
  251. Y.mix(Y_DOM.VALUE_SETTERS, {
  252. // IE: node.value changes the button text, which should be handled via innerHTML
  253. button: function(node, val) {
  254. _yuitest_coverfunc("build/dom-base/dom-base.js", "button", 174);
  255. _yuitest_coverline("build/dom-base/dom-base.js", 175);
  256. var attr = node.attributes.value;
  257. _yuitest_coverline("build/dom-base/dom-base.js", 176);
  258. if (!attr) {
  259. _yuitest_coverline("build/dom-base/dom-base.js", 177);
  260. attr = node[OWNER_DOCUMENT].createAttribute('value');
  261. _yuitest_coverline("build/dom-base/dom-base.js", 178);
  262. node.setAttributeNode(attr);
  263. }
  264. _yuitest_coverline("build/dom-base/dom-base.js", 181);
  265. attr.value = val;
  266. }
  267. });
  268. _yuitest_coverline("build/dom-base/dom-base.js", 186);
  269. Y.mix(Y_DOM.VALUE_GETTERS, {
  270. option: function(node) {
  271. _yuitest_coverfunc("build/dom-base/dom-base.js", "option", 187);
  272. _yuitest_coverline("build/dom-base/dom-base.js", 188);
  273. var attrs = node.attributes;
  274. _yuitest_coverline("build/dom-base/dom-base.js", 189);
  275. return (attrs.value && attrs.value.specified) ? node.value : node.text;
  276. },
  277. select: function(node) {
  278. _yuitest_coverfunc("build/dom-base/dom-base.js", "select", 192);
  279. _yuitest_coverline("build/dom-base/dom-base.js", 193);
  280. var val = node.value,
  281. options = node.options;
  282. _yuitest_coverline("build/dom-base/dom-base.js", 196);
  283. if (options && options.length) {
  284. // TODO: implement multipe select
  285. _yuitest_coverline("build/dom-base/dom-base.js", 198);
  286. if (node.multiple) {
  287. } else {_yuitest_coverline("build/dom-base/dom-base.js", 199);
  288. if (node.selectedIndex > -1) {
  289. _yuitest_coverline("build/dom-base/dom-base.js", 200);
  290. val = Y_DOM.getValue(options[node.selectedIndex]);
  291. }}
  292. }
  293. _yuitest_coverline("build/dom-base/dom-base.js", 204);
  294. return val;
  295. }
  296. });
  297. _yuitest_coverline("build/dom-base/dom-base.js", 207);
  298. var addClass, hasClass, removeClass;
  299. _yuitest_coverline("build/dom-base/dom-base.js", 209);
  300. Y.mix(Y.DOM, {
  301. /**
  302. * Determines whether a DOM element has the given className.
  303. * @method hasClass
  304. * @for DOM
  305. * @param {HTMLElement} element The DOM element.
  306. * @param {String} className the class name to search for
  307. * @return {Boolean} Whether or not the element has the given class.
  308. */
  309. hasClass: function(node, className) {
  310. _yuitest_coverfunc("build/dom-base/dom-base.js", "hasClass", 218);
  311. _yuitest_coverline("build/dom-base/dom-base.js", 219);
  312. var re = Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
  313. _yuitest_coverline("build/dom-base/dom-base.js", 220);
  314. return re.test(node.className);
  315. },
  316. /**
  317. * Adds a class name to a given DOM element.
  318. * @method addClass
  319. * @for DOM
  320. * @param {HTMLElement} element The DOM element.
  321. * @param {String} className the class name to add to the class attribute
  322. */
  323. addClass: function(node, className) {
  324. _yuitest_coverfunc("build/dom-base/dom-base.js", "addClass", 230);
  325. _yuitest_coverline("build/dom-base/dom-base.js", 231);
  326. if (!Y.DOM.hasClass(node, className)) { // skip if already present
  327. _yuitest_coverline("build/dom-base/dom-base.js", 232);
  328. node.className = Y.Lang.trim([node.className, className].join(' '));
  329. }
  330. },
  331. /**
  332. * Removes a class name from a given element.
  333. * @method removeClass
  334. * @for DOM
  335. * @param {HTMLElement} element The DOM element.
  336. * @param {String} className the class name to remove from the class attribute
  337. */
  338. removeClass: function(node, className) {
  339. _yuitest_coverfunc("build/dom-base/dom-base.js", "removeClass", 243);
  340. _yuitest_coverline("build/dom-base/dom-base.js", 244);
  341. if (className && hasClass(node, className)) {
  342. _yuitest_coverline("build/dom-base/dom-base.js", 245);
  343. node.className = Y.Lang.trim(node.className.replace(Y.DOM._getRegExp('(?:^|\\s+)' +
  344. className + '(?:\\s+|$)'), ' '));
  345. _yuitest_coverline("build/dom-base/dom-base.js", 248);
  346. if ( hasClass(node, className) ) { // in case of multiple adjacent
  347. _yuitest_coverline("build/dom-base/dom-base.js", 249);
  348. removeClass(node, className);
  349. }
  350. }
  351. },
  352. /**
  353. * Replace a class with another class for a given element.
  354. * If no oldClassName is present, the newClassName is simply added.
  355. * @method replaceClass
  356. * @for DOM
  357. * @param {HTMLElement} element The DOM element
  358. * @param {String} oldClassName the class name to be replaced
  359. * @param {String} newClassName the class name that will be replacing the old class name
  360. */
  361. replaceClass: function(node, oldC, newC) {
  362. _yuitest_coverfunc("build/dom-base/dom-base.js", "replaceClass", 263);
  363. _yuitest_coverline("build/dom-base/dom-base.js", 264);
  364. removeClass(node, oldC); // remove first in case oldC === newC
  365. _yuitest_coverline("build/dom-base/dom-base.js", 265);
  366. addClass(node, newC);
  367. },
  368. /**
  369. * If the className exists on the node it is removed, if it doesn't exist it is added.
  370. * @method toggleClass
  371. * @for DOM
  372. * @param {HTMLElement} element The DOM element
  373. * @param {String} className the class name to be toggled
  374. * @param {Boolean} addClass optional boolean to indicate whether class
  375. * should be added or removed regardless of current state
  376. */
  377. toggleClass: function(node, className, force) {
  378. _yuitest_coverfunc("build/dom-base/dom-base.js", "toggleClass", 277);
  379. _yuitest_coverline("build/dom-base/dom-base.js", 278);
  380. var add = (force !== undefined) ? force :
  381. !(hasClass(node, className));
  382. _yuitest_coverline("build/dom-base/dom-base.js", 281);
  383. if (add) {
  384. _yuitest_coverline("build/dom-base/dom-base.js", 282);
  385. addClass(node, className);
  386. } else {
  387. _yuitest_coverline("build/dom-base/dom-base.js", 284);
  388. removeClass(node, className);
  389. }
  390. }
  391. });
  392. _yuitest_coverline("build/dom-base/dom-base.js", 289);
  393. hasClass = Y.DOM.hasClass;
  394. _yuitest_coverline("build/dom-base/dom-base.js", 290);
  395. removeClass = Y.DOM.removeClass;
  396. _yuitest_coverline("build/dom-base/dom-base.js", 291);
  397. addClass = Y.DOM.addClass;
  398. _yuitest_coverline("build/dom-base/dom-base.js", 293);
  399. var re_tag = /<([a-z]+)/i,
  400. Y_DOM = Y.DOM,
  401. addFeature = Y.Features.add,
  402. testFeature = Y.Features.test,
  403. creators = {},
  404. createFromDIV = function(html, tag) {
  405. _yuitest_coverfunc("build/dom-base/dom-base.js", "createFromDIV", 302);
  406. _yuitest_coverline("build/dom-base/dom-base.js", 303);
  407. var div = Y.config.doc.createElement('div'),
  408. ret = true;
  409. _yuitest_coverline("build/dom-base/dom-base.js", 306);
  410. div.innerHTML = html;
  411. _yuitest_coverline("build/dom-base/dom-base.js", 307);
  412. if (!div.firstChild || div.firstChild.tagName !== tag.toUpperCase()) {
  413. _yuitest_coverline("build/dom-base/dom-base.js", 308);
  414. ret = false;
  415. }
  416. _yuitest_coverline("build/dom-base/dom-base.js", 311);
  417. return ret;
  418. },
  419. re_tbody = /(?:\/(?:thead|tfoot|tbody|caption|col|colgroup)>)+\s*<tbody/,
  420. TABLE_OPEN = '<table>',
  421. TABLE_CLOSE = '</table>';
  422. _yuitest_coverline("build/dom-base/dom-base.js", 319);
  423. Y.mix(Y.DOM, {
  424. _fragClones: {},
  425. _create: function(html, doc, tag) {
  426. _yuitest_coverfunc("build/dom-base/dom-base.js", "_create", 322);
  427. _yuitest_coverline("build/dom-base/dom-base.js", 323);
  428. tag = tag || 'div';
  429. _yuitest_coverline("build/dom-base/dom-base.js", 325);
  430. var frag = Y_DOM._fragClones[tag];
  431. _yuitest_coverline("build/dom-base/dom-base.js", 326);
  432. if (frag) {
  433. _yuitest_coverline("build/dom-base/dom-base.js", 327);
  434. frag = frag.cloneNode(false);
  435. } else {
  436. _yuitest_coverline("build/dom-base/dom-base.js", 329);
  437. frag = Y_DOM._fragClones[tag] = doc.createElement(tag);
  438. }
  439. _yuitest_coverline("build/dom-base/dom-base.js", 331);
  440. frag.innerHTML = html;
  441. _yuitest_coverline("build/dom-base/dom-base.js", 332);
  442. return frag;
  443. },
  444. _children: function(node, tag) {
  445. _yuitest_coverfunc("build/dom-base/dom-base.js", "_children", 335);
  446. _yuitest_coverline("build/dom-base/dom-base.js", 336);
  447. var i = 0,
  448. children = node.children,
  449. childNodes,
  450. hasComments,
  451. child;
  452. _yuitest_coverline("build/dom-base/dom-base.js", 342);
  453. if (children && children.tags) { // use tags filter when possible
  454. _yuitest_coverline("build/dom-base/dom-base.js", 343);
  455. if (tag) {
  456. _yuitest_coverline("build/dom-base/dom-base.js", 344);
  457. children = node.children.tags(tag);
  458. } else { // IE leaks comments into children
  459. _yuitest_coverline("build/dom-base/dom-base.js", 346);
  460. hasComments = children.tags('!').length;
  461. }
  462. }
  463. _yuitest_coverline("build/dom-base/dom-base.js", 350);
  464. if (!children || (!children.tags && tag) || hasComments) {
  465. _yuitest_coverline("build/dom-base/dom-base.js", 351);
  466. childNodes = children || node.childNodes;
  467. _yuitest_coverline("build/dom-base/dom-base.js", 352);
  468. children = [];
  469. _yuitest_coverline("build/dom-base/dom-base.js", 353);
  470. while ((child = childNodes[i++])) {
  471. _yuitest_coverline("build/dom-base/dom-base.js", 354);
  472. if (child.nodeType === 1) {
  473. _yuitest_coverline("build/dom-base/dom-base.js", 355);
  474. if (!tag || tag === child.tagName) {
  475. _yuitest_coverline("build/dom-base/dom-base.js", 356);
  476. children.push(child);
  477. }
  478. }
  479. }
  480. }
  481. _yuitest_coverline("build/dom-base/dom-base.js", 362);
  482. return children || [];
  483. },
  484. /**
  485. * Creates a new dom node using the provided markup string.
  486. * @method create
  487. * @param {String} html The markup used to create the element
  488. * @param {HTMLDocument} doc An optional document context
  489. * @return {HTMLElement|DocumentFragment} returns a single HTMLElement
  490. * when creating one node, and a documentFragment when creating
  491. * multiple nodes.
  492. */
  493. create: function(html, doc) {
  494. _yuitest_coverfunc("build/dom-base/dom-base.js", "create", 374);
  495. _yuitest_coverline("build/dom-base/dom-base.js", 375);
  496. if (typeof html === 'string') {
  497. _yuitest_coverline("build/dom-base/dom-base.js", 376);
  498. html = Y.Lang.trim(html); // match IE which trims whitespace from innerHTML
  499. }
  500. _yuitest_coverline("build/dom-base/dom-base.js", 380);
  501. doc = doc || Y.config.doc;
  502. _yuitest_coverline("build/dom-base/dom-base.js", 381);
  503. var m = re_tag.exec(html),
  504. create = Y_DOM._create,
  505. custom = creators,
  506. ret = null,
  507. creator,
  508. tag, nodes;
  509. _yuitest_coverline("build/dom-base/dom-base.js", 388);
  510. if (html != undefined) { // not undefined or null
  511. _yuitest_coverline("build/dom-base/dom-base.js", 389);
  512. if (m && m[1]) {
  513. _yuitest_coverline("build/dom-base/dom-base.js", 390);
  514. creator = custom[m[1].toLowerCase()];
  515. _yuitest_coverline("build/dom-base/dom-base.js", 391);
  516. if (typeof creator === 'function') {
  517. _yuitest_coverline("build/dom-base/dom-base.js", 392);
  518. create = creator;
  519. } else {
  520. _yuitest_coverline("build/dom-base/dom-base.js", 394);
  521. tag = creator;
  522. }
  523. }
  524. _yuitest_coverline("build/dom-base/dom-base.js", 398);
  525. nodes = create(html, doc, tag).childNodes;
  526. _yuitest_coverline("build/dom-base/dom-base.js", 400);
  527. if (nodes.length === 1) { // return single node, breaking parentNode ref from "fragment"
  528. _yuitest_coverline("build/dom-base/dom-base.js", 401);
  529. ret = nodes[0].parentNode.removeChild(nodes[0]);
  530. } else {_yuitest_coverline("build/dom-base/dom-base.js", 402);
  531. if (nodes[0] && nodes[0].className === 'yui3-big-dummy') { // using dummy node to preserve some attributes (e.g. OPTION not selected)
  532. _yuitest_coverline("build/dom-base/dom-base.js", 403);
  533. if (nodes.length === 2) {
  534. _yuitest_coverline("build/dom-base/dom-base.js", 404);
  535. ret = nodes[0].nextSibling;
  536. } else {
  537. _yuitest_coverline("build/dom-base/dom-base.js", 406);
  538. nodes[0].parentNode.removeChild(nodes[0]);
  539. _yuitest_coverline("build/dom-base/dom-base.js", 407);
  540. ret = Y_DOM._nl2frag(nodes, doc);
  541. }
  542. } else { // return multiple nodes as a fragment
  543. _yuitest_coverline("build/dom-base/dom-base.js", 410);
  544. ret = Y_DOM._nl2frag(nodes, doc);
  545. }}
  546. }
  547. _yuitest_coverline("build/dom-base/dom-base.js", 415);
  548. return ret;
  549. },
  550. _nl2frag: function(nodes, doc) {
  551. _yuitest_coverfunc("build/dom-base/dom-base.js", "_nl2frag", 418);
  552. _yuitest_coverline("build/dom-base/dom-base.js", 419);
  553. var ret = null,
  554. i, len;
  555. _yuitest_coverline("build/dom-base/dom-base.js", 422);
  556. if (nodes && (nodes.push || nodes.item) && nodes[0]) {
  557. _yuitest_coverline("build/dom-base/dom-base.js", 423);
  558. doc = doc || nodes[0].ownerDocument;
  559. _yuitest_coverline("build/dom-base/dom-base.js", 424);
  560. ret = doc.createDocumentFragment();
  561. _yuitest_coverline("build/dom-base/dom-base.js", 426);
  562. if (nodes.item) { // convert live list to static array
  563. _yuitest_coverline("build/dom-base/dom-base.js", 427);
  564. nodes = Y.Array(nodes, 0, true);
  565. }
  566. _yuitest_coverline("build/dom-base/dom-base.js", 430);
  567. for (i = 0, len = nodes.length; i < len; i++) {
  568. _yuitest_coverline("build/dom-base/dom-base.js", 431);
  569. ret.appendChild(nodes[i]);
  570. }
  571. } // else inline with log for minification
  572. _yuitest_coverline("build/dom-base/dom-base.js", 434);
  573. return ret;
  574. },
  575. /**
  576. * Inserts content in a node at the given location
  577. * @method addHTML
  578. * @param {HTMLElement} node The node to insert into
  579. * @param {HTMLElement | Array | HTMLCollection} content The content to be inserted
  580. * @param {HTMLElement} where Where to insert the content
  581. * If no "where" is given, content is appended to the node
  582. * Possible values for "where"
  583. * <dl>
  584. * <dt>HTMLElement</dt>
  585. * <dd>The element to insert before</dd>
  586. * <dt>"replace"</dt>
  587. * <dd>Replaces the existing HTML</dd>
  588. * <dt>"before"</dt>
  589. * <dd>Inserts before the existing HTML</dd>
  590. * <dt>"before"</dt>
  591. * <dd>Inserts content before the node</dd>
  592. * <dt>"after"</dt>
  593. * <dd>Inserts content after the node</dd>
  594. * </dl>
  595. */
  596. addHTML: function(node, content, where) {
  597. _yuitest_coverfunc("build/dom-base/dom-base.js", "addHTML", 458);
  598. _yuitest_coverline("build/dom-base/dom-base.js", 459);
  599. var nodeParent = node.parentNode,
  600. i = 0,
  601. item,
  602. ret = content,
  603. newNode;
  604. _yuitest_coverline("build/dom-base/dom-base.js", 466);
  605. if (content != undefined) { // not null or undefined (maybe 0)
  606. _yuitest_coverline("build/dom-base/dom-base.js", 467);
  607. if (content.nodeType) { // DOM node, just add it