Skip to content

Commit d26621a

Browse files
committed
Another fix for #41. It was still broken with attributes.
1 parent dd4af2c commit d26621a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/Element/XmlFragment.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function xmlSerialize(Writer $writer) {
8383
$writer->startElement(
8484
$reader->getClark()
8585
);
86+
$empty = $reader->isEmptyElement;
8687
while ($reader->moveToNextAttribute()) {
8788
switch($reader->namespaceURI) {
8889
case '' :
@@ -96,7 +97,7 @@ function xmlSerialize(Writer $writer) {
9697
break;
9798
}
9899
}
99-
if ($reader->isEmptyElement) {
100+
if ($empty) {
100101
$writer->endElement();
101102
}
102103
break;

tests/Sabre/XML/Element/XmlFragmentTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ function xmlProvider() {
9898
'<foo:element xmlns:foo="http://example.org/ns" xmlns="http://sabredav.org/ns"><child/></foo:element>',
9999
'<x1:element xmlns:x1="http://example.org/ns"><child/></x1:element>',
100100
],
101+
[
102+
'<foo:element xmlns:foo="http://example.org/ns"><child a="b"/></foo:element>',
103+
'<foo:element xmlns:foo="http://example.org/ns" xmlns="http://sabredav.org/ns"><child a="b"/></foo:element>',
104+
'<x1:element xmlns:x1="http://example.org/ns"><child a="b"/></x1:element>',
105+
],
101106
];
102107

103108
}

0 commit comments

Comments
 (0)