MCPcopy
hub / github.com/ampproject/amphtml / addAttributesToElement

Function addAttributesToElement

third_party/subscriptions-project/swg.js:3672–3688  ·  view source on GitHub ↗

* Add attributes to an element. * @param {!Element} element * @param {!Object >} attributes * @return {!Element} updated element.

(element, attributes)

Source from the content-addressed store, hash-verified

3670 * @return {!Element} updated element.
3671 */
3672function 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.

Callers 1

createElementFunction · 0.70

Calls 2

setStylesFunction · 0.70
setAttributeMethod · 0.45

Tested by

no test coverage detected