* Add attributes to an element. * @param {!Element} element * @param {!Object >} attributes * @return {!Element} updated element.
(element, attributes)
| 3670 | * @return {!Element} updated element. |
| 3671 | */ |
| 3672 | function addAttributesToElement(element, attributes) { |
| 3673 | for (const attr in attributes) { |
| 3674 | if (attr == 'style') { |
| 3675 | setStyles( |
| 3676 | element, |
| 3677 | /** @type {!Object<string, string|boolean|number>} */ |
| 3678 | (attributes[attr]) |
| 3679 | ); |
| 3680 | } else { |
| 3681 | element.setAttribute( |
| 3682 | attr, |
| 3683 | /** @type {string|boolean|number} */ (attributes[attr]) |
| 3684 | ); |
| 3685 | } |
| 3686 | } |
| 3687 | return element; |
| 3688 | } |
| 3689 | |
| 3690 | /** |
| 3691 | * Create a new element on document with specified tagName and attributes. |
no test coverage detected