* Return an attribute's value as a string. * * The first parameter, `name`, is a string with the name of the attribute * being checked. For example, calling `myXML.getString('color')` returns the * element's `id` attribute as a string. * * The second parameter, `defaultValue`, is o
(name, defaultValue)
| 898 | * } |
| 899 | */ |
| 900 | getString(name, defaultValue) { |
| 901 | const obj = {}; |
| 902 | |
| 903 | for (const attribute of this.DOM.attributes) { |
| 904 | obj[attribute.nodeName] = attribute.nodeValue; |
| 905 | } |
| 906 | |
| 907 | return obj[name] ? String(obj[name]) : defaultValue || null; |
| 908 | } |
| 909 | |
| 910 | /** |
| 911 | * Sets an attribute to a given value. |
no outgoing calls
no test coverage detected