src/Visitor/TagVisitorTrait.php
private function setAttributes(\DOMNode $domNode, TagNodeInterface $node, array $allowedAttributes = [])
    {
        if (!\count($domNode->attributes)) {
            return;
        }

        /** @var \DOMAttr $attribute */
        foreach ($domNode->attributes as $attribute) {
            $name = strtolower($attribute->name);

            if (\in_array($name, $allowedAttributes, true)) {
                $node->setAttribute($name, $attribute->value);
            }
        }
    }
private function setAttributes(\DOMNode $domNode, TagNodeInterface $node, array $allowedAttributes = [])
    {
        if (!\count($domNode->attributes)) {
            return;
        }

        /** @var \DOMAttr $attribute */
        foreach ($domNode->attributes as $attribute) {
            $name = strtolower($attribute->name);

            if (\in_array($name, $allowedAttributes, true)) {
                $node->setAttribute($name, $attribute->value);
            }
        }
    }
Set attributes from a DOM node to a sanitized node.

@param \DOMNode         $domNode
@param TagNodeInterface $node
@param array            $allowedAttributes