[Xsltforms-support] Patch suggestion for xsltforms.js
Brought to you by:
alain-couthures
From: Ivan P. <ipo...@ma...> - 2011-01-16 17:30:33
|
Hello, Alain, maybe you will find it reasonable to include the following patch for xforms.close() procedure in the next versions of XSLTforms. After xforms.dispose(document.documentElement); there should be a call to dropHasXFElement(document.documentElement); where dropHasXFElement is implemented as follows: function dropHasXFElement(element){ element.hasXFElement = null; var subelement = element.firstChild; while(subelement){ if (subelement.nodeType == NodeType.ELEMENT) dropHasXFElement(subelement); subelement = subelement.nextSibling; } } The rationale for this patch is following. We are using xsltforms in GWT environment, which means that we cannot reload the HTML page each time we have to show another form for the user. So we just 1) call xsltforms.close() to clean up everything, 2) remove <div> with the old form from page, 3) generate another portion of HTML+Javascript using xlstform.xsl, 4) put all this on page DYNAMICALLY in <div> and <script>s, 5) and then call init() procedure. The problem we faced was the unstable behavior of some forms starting from the second call of xsltforms.close(). I spent half a day in Firebug stepping through xlstforms.js and found out that the problem was in fact that Firefox uses OLD VALUES of hasXFElement attribute for DOM elements that were dynamically recreated. I think the code above is quite clear and it solves our problem. Regards, Ivan Ponomarev |