1 | ;
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.default = attribute;
|
5 |
|
6 | /**
|
7 | * Gets or sets an attribute of a given element.
|
8 | *
|
9 | * @param node the element
|
10 | * @param attr the attribute to get or set
|
11 | * @param val the attribute value
|
12 | */
|
13 | function attribute(node, attr, val) {
|
14 | if (node) {
|
15 | if (typeof val === 'undefined') {
|
16 | return node.getAttribute(attr);
|
17 | }
|
18 |
|
19 | if (!val && val !== '') {
|
20 | node.removeAttribute(attr);
|
21 | } else {
|
22 | node.setAttribute(attr, String(val));
|
23 | }
|
24 | }
|
25 | }
|
26 |
|
27 | module.exports = exports["default"]; |
\ | No newline at end of file |