(e, name)
| 201 | } |
| 202 | } |
| 203 | function toggleClass(e, name) { |
| 204 | /// <signature helpKeyword="WinJS.Utilities.toggleClass"> |
| 205 | /// <summary locid="WinJS.Utilities.toggleClass"> |
| 206 | /// Toggles (adds or removes) the specified class on the specified element. |
| 207 | /// If the class is present, it is removed; if it is absent, it is added. |
| 208 | /// </summary> |
| 209 | /// <param name="e" type="HTMLElement" locid="WinJS.Utilities.toggleClass_p:e"> |
| 210 | /// The element on which to toggle the class. |
| 211 | /// </param> |
| 212 | /// <param name="name" type="String" locid="WinJS.Utilities.toggleClass_p:name"> |
| 213 | /// The name of the class to toggle. |
| 214 | /// </param> |
| 215 | /// <returns type="HTMLElement" locid="WinJS.Utilities.toggleClass_returnValue"> |
| 216 | /// The element. |
| 217 | /// </returns> |
| 218 | /// </signature> |
| 219 | if (e.classList) { |
| 220 | e.classList.toggle(name); |
| 221 | return e; |
| 222 | } else { |
| 223 | var className = getClassName(e); |
| 224 | var names = className.trim().split(" "); |
| 225 | var l = names.length; |
| 226 | var found = false; |
| 227 | for (var i = 0; i < l; i++) { |
| 228 | if (names[i] === name) { |
| 229 | found = true; |
| 230 | } |
| 231 | } |
| 232 | if (!found) { |
| 233 | if (l > 0 && names[0].length > 0) { |
| 234 | setClassName(e, className + " " + name); |
| 235 | } else { |
| 236 | setClassName(e, className + name); |
| 237 | } |
| 238 | } else { |
| 239 | setClassName(e, names.reduce(function (r, e) { |
| 240 | if (e === name) { |
| 241 | return r; |
| 242 | } else if (r && r.length > 0) { |
| 243 | return r + " " + e; |
| 244 | } else { |
| 245 | return e; |
| 246 | } |
| 247 | }, "")); |
| 248 | } |
| 249 | return e; |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | // Only set the attribute if its value has changed |
| 254 | function setAttribute(element, attribute, value) { |
nothing calls this directly
no test coverage detected