dom-base.js revision 8647b185da5af4753fd23c77eafc9770e629bb36
/**
* @for DOM
* @module dom
*/
TAG_NAME = 'tagName',
OWNER_DOCUMENT = 'ownerDocument',
EMPTY_STRING = '',
/**
* 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).
*/
function(element) {
var ret = '';
if (element) {
}
return ret || '';
} : function(element) {
var ret = '';
if (element) {
}
return ret || '';
},
/**
* Sets the text content of the HTMLElement.
* @method setText
* @param {HTMLElement} element The html element.
* @param {String} content The content to add.
*/
if (element) {
}
if ('innerText' in element) {
} else if ('nodeValue' in element) {
}
},
'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.
*/
}
},
/**
* 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.
*/
var ret = '';
if (ret === null) {
}
}
return ret;
},
VALUE_SETTERS: {},
VALUE_GETTERS: {},
if (getter) {
} else {
}
}
// workaround for IE8 JSON stringify bug
// which converts empty string values to null
if (ret === EMPTY_STRING) {
}
},
var setter;
if (setter) {
} else {
}
}
},
creators: {}
});
test: function() {
}
});
//Y_DOM.setAttribute(option, 'selected', 'selected');
break;
}
}
}
}
}
});
// IE: node.value changes the button text, which should be handled via innerHTML
if (!attr) {
}
}
});
},
// TODO: implement multipe select
}
}
return val;
}
});
/**
* 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.
*/
},
/**
* 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
*/
}
},
/**
* 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
*/
}
}
},
/**
* 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
*/
},
/**
* 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
*/
if (add) {
} else {
}
}
});
var re_tag = /<([a-z]+)/i,
creators = {},
ret = true;
ret = false;
}
return ret;
},
TABLE_OPEN = '<table>',
TABLE_CLOSE = '</table>';
_fragClones: {},
if (frag) {
} else {
}
return frag;
},
var i = 0,
if (tag) {
} else { // IE leaks comments into children
}
}
children = [];
while ((child = childNodes[i++])) {
}
}
}
}
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.
*/
if (typeof html === 'string') {
}
ret = null,
if (m && m[1]) {
if (typeof creator === 'function') {
} else {
}
}
} else if (nodes[0] && nodes[0].className === 'yui3-big-dummy') { // using dummy node to preserve some attributes (e.g. OPTION not selected)
} else {
}
} else { // return multiple nodes as a fragment
}
}
return ret;
},
var ret = null,
i, len;
}
}
} // 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>
*/
i = 0,
item,
}
}
}
if (where) {
} else {
switch (where) {
case 'replace':
while (node.firstChild) {
}
if (newNode) { // allow empty content to clear node
}
break;
case 'before':
if (newNode) {
}
break;
case 'after':
if (newNode) {
} else {
}
}
break;
default:
if (newNode) {
}
}
}
} else if (newNode) {
}
return ret;
},
}
if (node.parentNode) {
}
},
if (parent) {
if (grandparent) {
}
} else {
}
}
}
});
test: function() {
try {
} catch(e) {
return false;
}
}
});
test: function() {
}
});
test: function() {
}
});
// IE adds TBODY when creating TABLE elements (which may share this impl)
}
return frag;
};
}
return frag;
}
}
return Y_DOM.create('<select><option class="yui3-big-dummy" selected></option>' + html + '</select>', doc);
},
},
},
},
tbody: 'table'
});
legend: 'fieldset',
});
}
/**
* 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
*/
},
/**
* 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
*/
},
var size = 0;
if (val < 0) {
val = 0;
}
}
}
});