Skip to content

Commit

Permalink
Another fix for #41. It was still broken with attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed Mar 21, 2015
1 parent dd4af2c commit d26621a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Element/XmlFragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function xmlSerialize(Writer $writer) {
$writer->startElement(
$reader->getClark()
);
$empty = $reader->isEmptyElement;
while ($reader->moveToNextAttribute()) {
switch($reader->namespaceURI) {
case '' :
Expand All @@ -96,7 +97,7 @@ function xmlSerialize(Writer $writer) {
break;
}
}
if ($reader->isEmptyElement) {
if ($empty) {
$writer->endElement();
}
break;
Expand Down
5 changes: 5 additions & 0 deletions tests/Sabre/XML/Element/XmlFragmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ function xmlProvider() {
'<foo:element xmlns:foo="http://example.org/ns" xmlns="http://sabredav.org/ns"><child/></foo:element>',
'<x1:element xmlns:x1="http://example.org/ns"><child/></x1:element>',
],
[
'<foo:element xmlns:foo="http://example.org/ns"><child a="b"/></foo:element>',
'<foo:element xmlns:foo="http://example.org/ns" xmlns="http://sabredav.org/ns"><child a="b"/></foo:element>',
'<x1:element xmlns:x1="http://example.org/ns"><child a="b"/></x1:element>',
],
];

}
Expand Down

0 comments on commit d26621a

Please sign in to comment.