* @param {String} attr attribute to set. * @param {String} value value to assign to the attribute. * @chainable
(attr, value)
| 1233 | * @chainable |
| 1234 | */ |
| 1235 | attribute(attr, value) { |
| 1236 | //handling for checkboxes and radios to ensure options get |
| 1237 | //attributes not divs |
| 1238 | if ( |
| 1239 | this.elt.firstChild != null && |
| 1240 | (this.elt.firstChild.type === 'checkbox' || |
| 1241 | this.elt.firstChild.type === 'radio') |
| 1242 | ) { |
| 1243 | if (typeof value === 'undefined') { |
| 1244 | return this.elt.firstChild.getAttribute(attr); |
| 1245 | } else { |
| 1246 | for (let i = 0; i < this.elt.childNodes.length; i++) { |
| 1247 | this.elt.childNodes[i].setAttribute(attr, value); |
| 1248 | } |
| 1249 | } |
| 1250 | } else if (typeof value === 'undefined') { |
| 1251 | return this.elt.getAttribute(attr); |
| 1252 | } else { |
| 1253 | this.elt.setAttribute(attr, value); |
| 1254 | return this; |
| 1255 | } |
| 1256 | } |
| 1257 | |
| 1258 | /** |
| 1259 | * Removes an attribute from the element. |
no test coverage detected