mirror of
https://github.com/RPCS3/pugixml.git
synced 2026-01-31 01:25:21 +01:00
Only save first PCDATA contents in the element
This change fixes an important ordering issue - if element node has a PCDATA child *after* other elements, it's impossible to tell which order the children were in. Since the goal of PCDATA embedding is to save memory when it's the only child, only apply the optimization to the first child. This seems to fix all roundtripping issues so the only caveat is that the DOM structure is different.
This commit is contained in:
@@ -3360,7 +3360,11 @@ PUGI__NS_BEGIN
|
||||
|
||||
if (cursor->parent || PUGI__OPTSET(parse_fragment))
|
||||
{
|
||||
if (!PUGI__OPTSET(parse_embed_pcdata))
|
||||
if (PUGI__OPTSET(parse_embed_pcdata) && cursor->parent && !cursor->first_child && !cursor->value)
|
||||
{
|
||||
cursor->value = s; // Save the offset.
|
||||
}
|
||||
else
|
||||
{
|
||||
PUGI__PUSHNODE(node_pcdata); // Append a new node on the tree.
|
||||
|
||||
@@ -3368,11 +3372,6 @@ PUGI__NS_BEGIN
|
||||
|
||||
PUGI__POPNODE(); // Pop since this is a standalone.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cursor->parent && !cursor->value)
|
||||
cursor->value = s; // Save the offset.
|
||||
}
|
||||
|
||||
s = strconv_pcdata(s);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user