Closed Bug 413354 Opened 17 years ago Closed 17 years ago

xform insert using origin and context into empty nodeset replaces context node instead of creating a child node

Categories

(Core Graveyard :: XForms, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 389016

People

(Reporter: andy, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11

xforms insert with origin and context works fine with an existing element in the nodeset but inserts the data replacing the context node (or inserts the data after the context node - in another test case thats too large to send) when the elements in the nodeset have been deleted.

Form Testcase: (or download from url)

<?xml version="1.0"?>
<?xml-stylesheet href="style.css" type="text/css"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<h:html 
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:c="urn:oasis:names:tc:ciq:xsdschema:xCIL:2.0" 
xmlns:nl="urn:oasis:names:tc:ciq:xsdschema:xNL:2.0"
xmlns:al="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events" 
xml:lang="en">
  <h:head>
    <h:title>Customer Details</h:title>
<!-- Initial instance data contains the prototypical node as the last element -->
<xf:model>
<xf:instance id="liveData" xmlns="">
   <cart>
<item>
<name>Test</name>

</item>
   </cart>
</xf:instance>

<xf:instance id="protoCart" xmlns="">
   <cart>
      <item>
          <name>Enter Value Here</name>
	</item>
   </cart>

</xf:instance>
</xf:model>
</h:head>
<h:body>

<!-- repeat operates over the live data -->

<xf:repeat nodeset="item" id="repeat-cart">
<xf:input ref="name">
<xf:label>Name:</xf:label>
</xf:input>

</xf:repeat>

<!-- Add new row after any current row, but do it in a way that can
     also handle zero rows. -->

<xf:trigger>
   <xf:label>Insert</xf:label>
   <xf:insert ev:event="DOMActivate" context="/cart" nodeset="item" 
                 at="index('repeat-cart')" position="after" 
                 origin="instance('protoCart')/item"/>
</xf:trigger>

<!-- Delete a row from the repeat.  -->

<xf:trigger>
   <xf:label>Delete</xf:label>
   <xf:delete ev:event="DOMActivate" context="/cart" nodeset="item" at="index('repeat-cart')"/>
</xf:trigger>

</h:body>
</h:html>


Reproducible: Always

Steps to Reproduce:
step 1 is just to show that it works ok

1) If you click on insert then the xforms buddy show the data as
<cart>
<item>
<name>Test</name>
</item><item>
          <name>Enter Value Here</name>
</item>
   </cart>
2) If you click on delete twice the model changes to 
<cart>

   </cart>
3) Now after clicking on insert the model changes to
<item>
          <name>Enter Value Here</name>
</item>
Actual Results:  
Model is
<item>
          <name>Enter Value Here</name>
</item>

Expected Results:  
<cart>
<item>
          <name>Enter Value Here</name>
</item>
   </cart>

This example works as expected in formsplayer in iexplorer and so it doesnt seem to be an error in the xform.

Its a serious bug for us as its stopping development of a web application with firefox and may mean we have to change to IE.
I think that this is a dupe of bug 389016 which is already fixed.  I tested this on the latest build from the 1.8 branch and your testcase works for me.  You should grab the latest 1.8 xforms nightly to get you around this problem until our next release of 0.8.x is out (hopefully quite soon...within next week or two).
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.