myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Koci <martin.kocicak.k...@gmail.com>
Subject Re: [core] Firefox 4 - <script> in XHR executed 2x?
Date Tue, 21 Jun 2011 18:03:37 GMT
Hi, 

collegue of me did this  a small test page (pasted below). Do you see
something wrong there? 

Thanks, 

Kočičák

<h:commandButton value="Reload panel">
            <f:ajax execute="@none" render="outputWriter" />
        </h:commandButton>
        
        <script type="text/javascript">
            var counter = 0;
            function writeCounter() {
                document.getElementById('output').innerHTML += (counter
++) + ' ';
            }
        </script>

        <h:panelGroup id="output" layout="block" style="width: 400px;
height: 400px; border: 1px solid black;" />

        <!--
        If this panelGroup contains only one script, it works well - the
script
        is evaluated only once - in runScripts() from jsf.js.
        But if it contains more script elements, the following code from
        jsf.js _outerHTMLCompliant() evaluates them first:  
        item.parentNode.replaceChild(ret, item);
        And then runScripts() evaluates them also.
        -->        
        <h:panelGroup id="outputWriter">
            <h:outputScript>
                writeCounter();
            </h:outputScript>
            
            <h:outputScript>var a;</h:outputScript>
        </h:panelGroup>


Werner Punz píše v Út 21. 06. 2011 v 19:17 +0200:
> Actually the problem sounds like you get an auto eval and then the 
> manual eval.
> However it also could be possible that you have the script twice in your 
> dom tree when the scripts are evaled.
> 
> 
> Werner
> 
> 
> Am 21.06.11 12:24, schrieb Martin Koci:
> > Hi,
> >
> > ok, I'll investigate it more; I'll try isolate  the problem in small
> > reproducible example, if possible. Most likely is problem in my code.
> >
> > Thanks,
> >
> > Kočičák
> >
> > Werner Punz píše v Po 20. 06. 2011 v 22:33 +0200:
> >> Am 20.06.11 21:18, schrieb Martin Koci:
> >>> Hi,
> >>>
> >>> I'm not very familiar with JavaScript, so I ask first if it is bug or
> >>> not:
> >>>
> >>> If<script>   element is in XHR response, who is responsible for execute
> >>> that script? I found [1] so I suppose that runScripts function does it
> >>> in MyFaces. With Firefox 4 it seems that<script>   is executed 2x:
first
> >>> time when DOM is replaced and second time from runScripts function. But
> >>> I didn't debug it much ...  problem can be anywhere else. I don't have
> >>> this problem with Firefox 3.6.
> >>>
> >>>
> >>> Thanks,
> >>>
> >>> Kočičák
> >>>
> >>> [1] http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-724
> >>>
> >>>
> >> Ok this is strange because it actually should not happen due to two reasons.
> >> a) Firefox does not do any auto eval post 3.6
> >> b) I have auto eval detection code which is browser independend
> >> by adding a small inline script post load which sets a global variable.
> >>
> >>
> >> This is actually one of my standard testcases and firefox 4 one of my
> >> testing targets so this should have been crawled up at my last testing
> >> cycle.
> >> I will investigate this issue this week nevertheless, which platform do
> >> you get the double eval and which exact Firefox version?
> >>
> >>
> >> Werner
> >>
> >>
> >
> >
> >
> 
> 
> 



Mime
View raw message