Closed iongion closed 5 years ago
When you say browser do you mean the browser's console? Can you post a test case so I can reproduce?
Check this sample https://codesandbox.io/s/8gqnv and this with the old version https://codesandbox.io/s/u7sz0
The end
function returns the string representation of the XML document. But in your samples, you are not using this string anywhere. Please see: https://codesandbox.io/s/muddy-grass-xrq7x for the correct usage.
@oozcitak But what is the toString() on doc doing ? Why did behavior change between releases ?
end
simply calls toString
on the document node. It is only a convenience method. You can also do doc().toString({ pretty: true })
. However, in your sample you were calling toString
without the pretty
argument. So the old behavior you were seeing was actually a bug. toString
shouldn't produce newlines when not pretty-printing. This was fixed in v11.0.0
.
As to why this happened: before v11 pretty printing flag would persist between toString and end calls. Once it was set all following calls would pretty print even if the flag was not set. This was a bug and was fixed. Here is the relevant issue: https://github.com/oozcitak/xmlbuilder-js/issues/120
Hi, since version
10.1.0
(the last one working) the pretty printing does not work on browsers anymore.Can you fix it ? There are some parsers that are stupid with missing newlines, they shouldn't, but it happens.