node-base-debug.js revision c52e955a422e7b83529a193e97b9dd2efb4f9df7
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @module node
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @submodule node-base
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Determines whether each node has the given className.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method hasClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to search for
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @return {Boolean} Whether or not the element has the specified class
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Adds a class name to each node.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method addClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to add to the node's class attribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Removes a class name from each node.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method removeClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to remove from the node's class attribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'removeClass',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Replace a class with another class for each node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If no oldClassName is present, the newClassName is simply added.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method replaceClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} oldClassName the class name to be replaced
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} newClassName the class name that will be replacing the old class name
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'replaceClass',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the className exists on the node it is removed, if it doesn't exist it is added.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method toggleClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to be toggled
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Boolean} force Option to force adding or removing the class.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'toggleClass'
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Determines whether each node has the given className.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method hasClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.hasClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to search for
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @return {Array} An array of booleans for each node bound to the NodeList.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Adds a class name to each node.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method addClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.addClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to add to the node's class attribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Removes a class name from each node.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method removeClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.removeClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to remove from the node's class attribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Replace a class with another class for each node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If no oldClassName is present, the newClassName is simply added.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method replaceClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.replaceClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} oldClassName the class name to be replaced
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} newClassName the class name that will be replacing the old class name
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the className exists on the node it is removed, if it doesn't exist it is added.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method toggleClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.toggleClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to be toggled
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt SweeneyY.NodeList.importMethod(Y.Node.prototype, methods);
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @module node
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @submodule node-base
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Returns a new dom node using the provided markup string.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @method create
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {String} html The markup used to create the element
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {HTMLDocument} doc An optional document context
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @return {Node} A Node instance bound to a DOM node or fragment
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Creates a new Node using the provided markup string.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method create
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} html The markup used to create the element
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {HTMLDocument} doc An optional document context
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @return {Node} A Node instance bound to a DOM node or fragment
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Inserts the content before the reference node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method insert
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {String | Node | HTMLElement | NodeList | HTMLCollection} content The content to insert
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {Int | Node | HTMLElement | String} where The position to insert at.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Possible "where" arguments
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>Y.Node</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>The Node to insert before</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>HTMLElement</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>The element to insert before</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>Int</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>The index of the child element to insert before</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>"replace"</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>Replaces the existing HTML</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>"before"</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>Inserts before the existing HTML</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>"before"</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>Inserts content before the node</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>"after"</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>Inserts content after the node</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return this;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney if (content && typeof content != 'string') { // allow Node or NodeList/Array instances
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney content = content._node || content._nodes || content;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Inserts the content as the firstChild of the node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method prepend
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {String | Node | HTMLElement} content The content to insert
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Inserts the content as the lastChild of the node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method append
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {String | Node | HTMLElement} content The content to insert
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method appendChild
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String | HTMLElement | Node} node Node to be appended
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @return {Node} The appended node
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method insertBefore
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String | HTMLElement | Node} newNode Node to be appended
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {HTMLElement | Node} refNode Node to be inserted before
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @return {Node} The inserted node
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return Y.Node.scrubVal(this._insert(newNode, refNode));
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * Appends the node to the given node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method appendTo
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {Node | HTMLElement} node The node to append to
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Replaces the node's current content with the content.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method setContent
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {String | Node | HTMLElement | NodeList | HTMLCollection} content The content to insert
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * Returns the node's current content (e.g. innerHTML)
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method getContent
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @return {String} The current content
2895ebd7cac94f09e29d6fc2b4aa601ca686cbe6Matt Sweeney * Replaces the node's current html content with the content provided.
2895ebd7cac94f09e29d6fc2b4aa601ca686cbe6Matt Sweeney * @method setHTML
2895ebd7cac94f09e29d6fc2b4aa601ca686cbe6Matt Sweeney * @param {String | HTML | Node | HTMLElement | NodeList | HTMLCollection} content The content to insert
2895ebd7cac94f09e29d6fc2b4aa601ca686cbe6Matt Sweeney * @chainable
2895ebd7cac94f09e29d6fc2b4aa601ca686cbe6Matt SweeneyY.Node.prototype.setHTML = Y.Node.prototype.setContent;
2895ebd7cac94f09e29d6fc2b4aa601ca686cbe6Matt Sweeney * Returns the node's current html content (e.g. innerHTML)
2895ebd7cac94f09e29d6fc2b4aa601ca686cbe6Matt Sweeney * @method getContent
2895ebd7cac94f09e29d6fc2b4aa601ca686cbe6Matt Sweeney * @return {String} The html content
2895ebd7cac94f09e29d6fc2b4aa601ca686cbe6Matt SweeneyY.Node.prototype.getHTML = Y.Node.prototype.getContent;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method append
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.append
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method insert
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.insert
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method appendChild
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.appendChild
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'appendChild',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method insertBefore
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.insertBefore
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'insertBefore',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method prepend
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.prepend
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method setContent
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.setContent
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'setContent',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method getContent
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.getContent
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'getContent'
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @module node
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @submodule node-base
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Static collection of configuration attributes for special handling
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @property ATTRS
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @type object
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Allows for getting and setting the text of an element.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Formatting is preserved and special characters are treated literally.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @config text
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @type String
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Allows for getting and setting the text of an element.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Formatting is preserved and special characters are treated literally.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @config for
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @type String
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'options': {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return this._node.getElementsByTagName('option');
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Returns a NodeList instance of all HTMLElement children.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @config children
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @type NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'children': {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney for (i = 0, len = childNodes.length; i < len; ++i) {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Allows setting attributes on DOM nodes, normalizing in some cases.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * This passes through to the DOM node, allowing for custom attributes.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method setAttribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {string} name The attribute name
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {string} value The value to set
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'setAttribute',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Allows getting attributes on DOM nodes, normalizing in some cases.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * This passes through to the DOM node, allowing for custom attributes.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method getAttribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @for NodeList
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {string} name The attribute name
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @return {string} The attribute value
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'getAttribute'
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @module node
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @submodule node-base
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * List of events that route to DOM events
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @property DOM_EVENTS
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney// Add custom event adaptors to this list. This will make it so
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney// that delegate, key, available, contentready, etc all will
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney// be available through Node.on
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Removes event listeners from the node and (optionally) its subtree
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method purge
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {Boolean} recurse (optional) Whether or not to remove listeners from the
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * node's subtree
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} type (optional) Only remove listeners of the specified type
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney Y.Event.purgeElement(this._node, recurse, type);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // map to Y.on/after signature (type, fn, nodes, context, arg1, arg2, etc)
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (args.length < 2) { // type only (event hash) just add nodes
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass args[3] = context || this; // default to NodeList instance as context
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith Subscribe a callback function for each `Node` in the collection to execute
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith in response to a DOM event.
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith NOTE: Generally, the `on()` method should be avoided on `NodeLists`, in
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith favor of using event delegation from a parent Node. See the Event user
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith guide for details.
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith Most DOM events are associated with a preventable default behavior, such as
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith link clicks navigating to a new page. Callbacks are passed a
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith `DOMEventFacade` object as their first argument (usually called `e`) that
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith can be used to prevent this default behavior with `e.preventDefault()`. See
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith the `DOMEventFacade` API for all available properties and methods on the
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith By default, the `this` object will be the `NodeList` that the subscription
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith came from, <em>not the `Node` that received the event</em>. Use
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith `e.currentTarget` to refer to the `Node`.
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith Returning `false` from a callback is supported as an alternative to calling
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith `e.preventDefault(); e.stopPropagation();`. However, it is recommended to
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith use the event methods.
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith Y.all(".sku").on("keydown", function (e) {
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith if (e.keyCode === 13) {
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith e.preventDefault();
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith // Use e.currentTarget to refer to the individual Node
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith var item = Y.MyApp.searchInventory( e.currentTarget.get('value') );
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith @param {String} type The name of the event
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith @param {Function} fn The callback to execute in response to the event
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith @param {Object} [context] Override `this` object in callback
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith @param {Any} [arg*] 0..n additional arguments to supply to the subscriber
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith @return {EventHandle} A subscription handle capable of detaching that
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith subscription
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return Y.on.apply(Y, this._prepEvtArgs.apply(this, arguments));
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Applies an one-time event listener to each Node bound to the NodeList.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method once
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} type The event being listened for
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {Function} fn The handler to call when the event fires
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {Object} context The context to call the handler with.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Default is the NodeList instance.
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith * @return {EventHandle} A subscription handle capable of detaching that
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith * subscription
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return Y.once.apply(Y, this._prepEvtArgs.apply(this, arguments));
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Applies an event listener to each Node bound to the NodeList.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * The handler is called only after all on() handlers are called
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * and the event is not prevented.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method after
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} type The event being listened for
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {Function} fn The handler to call when the event fires
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {Object} context The context to call the handler with.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Default is the NodeList instance.
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith * @return {EventHandle} A subscription handle capable of detaching that
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith * subscription
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return Y.after.apply(Y, this._prepEvtArgs.apply(this, arguments));
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * Applies an one-time event listener to each Node bound to the NodeList
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * that will be called only after all on() handlers are called and the
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * event is not prevented.
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * @method onceAfter
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * @param {String} type The event being listened for
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * @param {Function} fn The handler to call when the event fires
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * @param {Object} context The context to call the handler with.
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * Default is the NodeList instance.
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith * @return {EventHandle} A subscription handle capable of detaching that
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith * subscription
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith * @for NodeList
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith return Y.onceAfter.apply(Y, this._prepEvtArgs.apply(this, arguments));
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method detach
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.detach
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method detachAll
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.detachAll
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith * @for NodeList
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke SmithSubscribe a callback function to execute in response to a DOM event or custom
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke SmithMost DOM events are associated with a preventable default behavior such as
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smithlink clicks navigating to a new page. Callbacks are passed a `DOMEventFacade`
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smithobject as their first argument (usually called `e`) that can be used to
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smithprevent this default behavior with `e.preventDefault()`. See the
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith`DOMEventFacade` API for all available properties and methods on the object.
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke SmithIf the event name passed as the first parameter is not a whitelisted DOM event,
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smithit will be treated as a custom event subscriptions, allowing
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith`node.fire('customEventName')` later in the code. Refer to the Event user guide
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smithfor the full DOM event whitelist.
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke SmithBy default, the `this` object in the callback will refer to the subscribed
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke SmithReturning `false` from a callback is supported as an alternative to calling
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith`e.preventDefault(); e.stopPropagation();`. However, it is recommended to use
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smiththe event methods.
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith Y.one("#my-form").on("submit", function (e) {
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith e.preventDefault();
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith // proceed with ajax form submission instead...
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith@param {String} type The name of the event
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith@param {Function} fn The callback to execute in response to the event
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith@param {Object} [context] Override `this` object in callback
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith@param {Any} [arg*] 0..n additional arguments to supply to the subscriber
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith@return {EventHandle} A subscription handle capable of detaching that
64ae29f70cf52f95ff7dce4a531f576a0b805ff7Luke Smith subscription
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney setter: function(h) {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney setter: function(w) {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney sizeTo: function(w, h) {
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @module node
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @submodule node-base
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Makes the node visible.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the "transition" module is loaded, show optionally
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * animates the showing of the node using either the default
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * transition effect ('fadeIn'), or the given named effect.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method show
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String} name A named Transition effect to use as the show effect.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Object} config Options to use with the transition.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Function} callback An optional function to run after the transition completes.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return this;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * The implementation for showing nodes.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Default is to toggle the style.display property.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method _show
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @protected
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney _show: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return Y.DOM.getStyle(this._node, 'display') === 'none';
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove // base on current state if not forcing
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return this;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Hides the node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the "transition" module is loaded, hide optionally
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * animates the hiding of the node using either the default
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * transition effect ('fadeOut'), or the given named effect.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method hide
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String} name A named Transition effect to use as the show effect.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Object} config Options to use with the transition.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Function} callback An optional function to run after the transition completes.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return this;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * The implementation for hiding nodes.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Default is to toggle the style.display property.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method _hide
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @protected
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney _hide: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Makes each node visible.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the "transition" module is loaded, show optionally
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * animates the showing of the node using either the default
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * transition effect ('fadeIn'), or the given named effect.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method show
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String} name A named Transition effect to use as the show effect.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Object} config Options to use with the transition.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Function} callback An optional function to run after the transition completes.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @for NodeList
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Hides each node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the "transition" module is loaded, hide optionally
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * animates the hiding of the node using either the default
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * transition effect ('fadeOut'), or the given named effect.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method hide
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String} name A named Transition effect to use as the show effect.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Object} config Options to use with the transition.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Function} callback An optional function to run after the transition completes.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'toggleView'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glassif (!Y.config.doc.documentElement.hasAttribute) { // IE < 8
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (this.get('value') !== "") { // IE < 8 fails to populate specified when set in HTML
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return true;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass// IE throws an error when calling focus() on an element that's invisible, not
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass// displayed, or disabled.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } catch (e) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.log('error focusing node: ' + e.toString(), 'error', 'node');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass// IE throws error when setting input.type = 'hidden',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass// input.setAttribute('type', 'hidden') and input.attributes.type.value = 'hidden'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } catch(e) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass try { // IE errors when changing the type from "hidden'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } catch (e) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.log('error setting type: ' + val, 'info', 'node');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass getter: function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass _bypassProxy: true // don't update DOM when using with Attribute
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glassif (Y.config.doc.createElement('form').elements.nodeType) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // IE: elements collection is also FORM node which trips up scrubVal.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass getter: function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this.all('input, textarea, button, select');
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * Provides methods for managing custom Node data.
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @module node
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @main node
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @submodule node-data
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney if (! ('_data' in this)) {
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @method getData
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @description Retrieves arbitrary data stored on a Node instance.
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * If no data is associated with the Node, it will attempt to retrieve
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * a value from the corresponding HTML data attribute. (e.g. node.getData('foo')
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * will check node.getAttribute('data-foo')).
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @param {string} name Optional name of the data field to retrieve.
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * If no name is given, all data is returned.
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @return {any | Object} Whatever is stored at the given field,
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * or an object hash of all fields.
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney } else { // initialize from HTML attribute
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney } else if (typeof data == 'object' && data !== null) { // all fields
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney while (i < len) {
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney if (!(name in ret)) { // only merge if not already stored
c52e955a422e7b83529a193e97b9dd2efb4f9df7Matt Sweeney data = attrs && attrs[name] && attrs[name].value;
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @method setData
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @description Stores arbitrary data on a Node instance.
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * This is not stored with the DOM node.
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @param {string} name The name of the field to set. If no name
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * is given, name is treated as the data and overrides any existing data.
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @param {any} val The value to be assigned to the field.
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @chainable
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney return this;
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @method clearData
44d4f272b35aec28ecaacadf6bc6eb497fd509d3Matt Sweeney * @description Clears internally stored data.
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @param {string} name The name of the field to clear. If no name
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * is given, all data is cleared.
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney * @chainable
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney if ('_data' in this) {
880f76ee227b05b889736151e137e61c7bbf950dMatt Sweeney return this;
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @method getData
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @description Retrieves arbitrary data stored on each Node instance
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * bound to the NodeList.
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @param {string} name Optional name of the data field to retrieve.
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * If no name is given, all data is returned.
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @return {Array} An array containing all of the data for each Node instance.
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * or an object hash of all fields.
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @method setData
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @description Stores arbitrary data on each Node instance bound to the
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * NodeList. This is not stored with the DOM node.
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @param {string} name The name of the field to set. If no name
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * is given, name is treated as the data and overrides any existing data.
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @param {any} val The value to be assigned to the field.
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @chainable
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney var args = (arguments.length > 1) ? [name, val] : [name];
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @method clearData
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @description Clears data on all Node instances bound to the NodeList.
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @param {string} name The name of the field to clear. If no name
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * is given, all data is cleared.
f3a7e54fed783ecf7736b0004e4cc67314eca47dMatt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney}, '@VERSION@' ,{requires:['dom-base', 'node-core', 'event-base']});