API Docs for: 3.18.1
Show:

File: node/js/node-imports.js

  1. /**
  2. * @module node
  3. * @submodule node-core
  4. */
  5.  
  6. Y.Array.each([
  7. /**
  8. * Passes through to DOM method.
  9. * @for Node
  10. * @method removeChild
  11. * @param {HTMLElement | Node} node Node to be removed
  12. * @return {Node} The removed node
  13. */
  14. 'removeChild',
  15.  
  16. /**
  17. * Passes through to DOM method.
  18. * @method hasChildNodes
  19. * @return {Boolean} Whether or not the node has any childNodes
  20. */
  21. 'hasChildNodes',
  22.  
  23. /**
  24. * Passes through to DOM method.
  25. * @method cloneNode
  26. * @param {Boolean} deep Whether or not to perform a deep clone, which includes
  27. * subtree and attributes
  28. * @return {Node} The clone
  29. */
  30. 'cloneNode',
  31.  
  32. /**
  33. * Passes through to DOM method.
  34. * @method hasAttribute
  35. * @param {String} attribute The attribute to test for
  36. * @return {Boolean} Whether or not the attribute is present
  37. */
  38. 'hasAttribute',
  39.  
  40. /**
  41. * Passes through to DOM method.
  42. * @method scrollIntoView
  43. * @chainable
  44. */
  45. 'scrollIntoView',
  46.  
  47. /**
  48. * Passes through to DOM method.
  49. * @method getElementsByTagName
  50. * @param {String} tagName The tagName to collect
  51. * @return {NodeList} A NodeList representing the HTMLCollection
  52. */
  53. 'getElementsByTagName',
  54.  
  55. /**
  56. * Passes through to DOM method.
  57. * @method focus
  58. * @chainable
  59. */
  60. 'focus',
  61.  
  62. /**
  63. * Passes through to DOM method.
  64. * @method blur
  65. * @chainable
  66. */
  67. 'blur',
  68.  
  69. /**
  70. * Passes through to DOM method.
  71. * Only valid on FORM elements
  72. * @method submit
  73. * @chainable
  74. */
  75. 'submit',
  76.  
  77. /**
  78. * Passes through to DOM method.
  79. * Only valid on FORM elements
  80. * @method reset
  81. * @chainable
  82. */
  83. 'reset',
  84.  
  85. /**
  86. * Passes through to DOM method.
  87. * @method select
  88. * @chainable
  89. */
  90. 'select',
  91.  
  92. /**
  93. * Passes through to DOM method.
  94. * Only valid on TABLE elements
  95. * @method createCaption
  96. * @chainable
  97. */
  98. 'createCaption'
  99.  
  100. ], function(method) {
  101. Y.log('adding: ' + method, 'info', 'node');
  102. Y.Node.prototype[method] = function(arg1, arg2, arg3) {
  103. var ret = this.invoke(method, arg1, arg2, arg3);
  104. return ret;
  105. };
  106. });
  107.  
  108. /**
  109. * Passes through to DOM method.
  110. * @method removeAttribute
  111. * @param {String} attribute The attribute to be removed
  112. * @chainable
  113. */
  114. // one-off implementation due to IE returning boolean, breaking chaining
  115. Y.Node.prototype.removeAttribute = function(attr) {
  116. var node = this._node;
  117. if (node) {
  118. node.removeAttribute(attr, 0); // comma zero for IE < 8 to force case-insensitive
  119. }
  120.  
  121. return this;
  122. };
  123.  
  124. Y.Node.importMethod(Y.DOM, [
  125. /**
  126. * Determines whether the node is an ancestor of another HTML element in the DOM hierarchy.
  127. * @method contains
  128. * @param {Node | HTMLElement} needle The possible node or descendent
  129. * @return {Boolean} Whether or not this node is the needle its ancestor
  130. */
  131. 'contains',
  132. /**
  133. * Allows setting attributes on DOM nodes, normalizing in some cases.
  134. * This passes through to the DOM node, allowing for custom attributes.
  135. * @method setAttribute
  136. * @for Node
  137. * @chainable
  138. * @param {string} name The attribute name
  139. * @param {string} value The value to set
  140. */
  141. 'setAttribute',
  142. /**
  143. * Allows getting attributes on DOM nodes, normalizing in some cases.
  144. * This passes through to the DOM node, allowing for custom attributes.
  145. * @method getAttribute
  146. * @for Node
  147. * @param {string} name The attribute name
  148. * @return {string} The attribute value
  149. */
  150. 'getAttribute',
  151.  
  152. /**
  153. * Wraps the given HTML around the node.
  154. * @method wrap
  155. * @param {String} html The markup to wrap around the node.
  156. * @chainable
  157. * @for Node
  158. */
  159. 'wrap',
  160.  
  161. /**
  162. * Removes the node's parent node.
  163. * @method unwrap
  164. * @chainable
  165. */
  166. 'unwrap',
  167.  
  168. /**
  169. * Applies a unique ID to the node if none exists
  170. * @method generateID
  171. * @return {String} The existing or generated ID
  172. */
  173. 'generateID'
  174. ]);
  175.  
  176. Y.NodeList.importMethod(Y.Node.prototype, [
  177. /**
  178. * Allows getting attributes on DOM nodes, normalizing in some cases.
  179. * This passes through to the DOM node, allowing for custom attributes.
  180. * @method getAttribute
  181. * @see Node
  182. * @for NodeList
  183. * @param {string} name The attribute name
  184. * @return {string} The attribute value
  185. */
  186.  
  187. 'getAttribute',
  188. /**
  189. * Allows setting attributes on DOM nodes, normalizing in some cases.
  190. * This passes through to the DOM node, allowing for custom attributes.
  191. * @method setAttribute
  192. * @see Node
  193. * @for NodeList
  194. * @chainable
  195. * @param {string} name The attribute name
  196. * @param {string} value The value to set
  197. */
  198. 'setAttribute',
  199.  
  200. /**
  201. * Allows for removing attributes on DOM nodes.
  202. * This passes through to the DOM node, allowing for custom attributes.
  203. * @method removeAttribute
  204. * @see Node
  205. * @for NodeList
  206. * @param {string} name The attribute to remove
  207. */
  208. 'removeAttribute',
  209. /**
  210. * Removes the parent node from node in the list.
  211. * @method unwrap
  212. * @chainable
  213. */
  214. 'unwrap',
  215. /**
  216. * Wraps the given HTML around each node.
  217. * @method wrap
  218. * @param {String} html The markup to wrap around the node.
  219. * @chainable
  220. */
  221. 'wrap',
  222.  
  223. /**
  224. * Applies a unique ID to each node if none exists
  225. * @method generateID
  226. * @return {String} The existing or generated ID
  227. */
  228. 'generateID'
  229. ]);
  230.