Skip to content

Commit

Permalink
Avoid broken XML-output when no prefix is set
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Sep 6, 2024
1 parent c76769a commit 900bfed
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public function getNamespaceURI(): ?string
/**
* Collect the value of the namespacePrefix-property
*
* @return string
* @return string|null
*/
public function getNamespacePrefix(): string
public function getNamespacePrefix(): ?string
{
return $this->namespacePrefix;
}
Expand Down Expand Up @@ -108,7 +108,9 @@ public function toXML(DOMElement $parent): DOMElement
{
$parent->setAttributeNS(
$this->getNamespaceURI(),
$this->getNamespacePrefix() . ':' . $this->getAttrName(),
($this->getNamespacePrefix() !== null)
? ($this->getNamespacePrefix() . ':' . $this->getAttrName())
: $this->getAttrName(),
$this->getAttrValue(),
);

Expand Down

0 comments on commit 900bfed

Please sign in to comment.