User-Agent: Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11 Build Identifier: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 I've an XUL tree element with querytype="xml" attribute set. Tree element is populated from XML datasource. Datasource has the following format: <items> <item name="A" id="1"> <item name="A child 1" id="2"/> <item name="A child 1" id="3"/> </item> <item name="B" id="4"> <item name="C" id="5"> <item name="C child 1" id="6"/> </item> </items> The bug is that tree twisty state won't persist. For example, if I open items A and C using twisty button, they won't stay open after window reload. For comparison. If RDF datasource is used and "rdf:about" attribute is present on items A and C, tree remembers twisty state correctly, that is, if I open children of item A and then reload my XUL window, item A remains opened. Reproducible: Always Steps to Reproduce: 1. Prepare XML datasource with nested levels, with "id" attributes for each item 2. Prepare XUL tree with template, which will generate nested treeitems if recursive datasource is attached 3. Attach XML datasource from step 1 to tree from step 2. Make sure, that tree has nested treeitems, which can be opened/closed using twisty button. 4. Open any treeitem to see its children 5. Reload window Actual Results: Opened treeitem appears closed after reloading window. Expected Results: Opened treeitem should stay opened after reloading window if "id" attribute is present in XML datasource Such behavior was observed under both 32 and 64 bit Windows for all Firefox/XULRunner versions with XML datasource support.
Created attachment 538968 [details] [diff] [review] fix This patch fixes this issue. Two comments about the testcase that would need to be changed: - an xml id needs to be declared in the xml source - the patch only works for dont-build-content trees
Comment on attachment 538968 [details] [diff] [review] fix This patch generates the id from the source node's id, rather than using a random value. This way it is always the same each time so persistence can work.
Comment on attachment 538968 [details] [diff] [review] fix Is it documented somewhere how this stuff works? And that we're recommending that you put an id on the relevant elements?
The idea is that the datasource nodes should have ids if you plan to you the persist feature with them. Persisting of open tree nodes is part of the tree builder, so ids are needed there. However, if you don't want or need persistence, then ids aren't necessary.
Sure, but we still need to document this somewhere other than In this bug.
My comment 6 is intended to be a summary to be used by someone documenting this.
Looking for suggestions on appropriate places to document this. Would this be one? https://developer.mozilla.org/en/XUL/treeitem Any other suggestions? This isn't an area of the docs I've done much with, so I want to be sure to get it right.
Added notes: https://developer.mozilla.org/en/XUL/Template_Guide/Building_Trees#Using_Tree_Properties https://developer.mozilla.org/en/XUL/Template_Guide/XML_Templates And mentioned on Firefox 7 for developers.
I've added flags="dont-build-content" to XUL tree in the example bug.xul attached above, but treeitem state still doesn't persist. I am using Firefox 7