Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.4.2

Bug #8684 Problem with generated JavaScript.
Submitted: 2006-09-13 11:35 UTC
From: ipa at assis dot lt Assigned: farell
Status: Closed Package: HTML_Progress2 (version 2.1.0)
PHP Version: Irrelevant OS: All
Roadmaps: (Not assigned)    
Subscription  


 [2006-09-13 11:35 UTC] ipa at assis dot lt (Ilja Polivanovas)
Description: ------------ In generated Javascript functions variable `name` is not in local scope. Therefore beeing global, that functions modify window.name property. In that case it can brake HTML links from working properly. Test script: --------------- HTML_Progress2 generates: function showCell(pCell, pIdent, pVisibility) { name = '%progressCell%' + pCell + 'A' + pIdent; document.getElementById(name).style.visibility = pVisibility; } function hideProgress(pIdent, pCellCount) { name = 'tfrm' + pIdent; document.getElementById(name).style.visibility = 'hidden'; for (i = 0; i < pCellCount; i++) { showCell(i, pIdent, 'hidden'); } } function setLabelText(pIdent, pName, pText) { name = 'plbl' + pName + pIdent; document.getElementById(name).firstChild.nodeValue = pText; } function setElementStyle(pPrefix, pName, pIdent, pStyles) { name = pPrefix + pName + pIdent; styles = pStyles.split(';'); styles.pop(); for (i = 0; i < styles.length; i++) { s = styles[i].split(':'); c = 'document.getElementById(name).style.' + s[0] + '="' + s[1] + '"'; eval(c); } } function setRotaryCross(pIdent, pName) { name = 'plbl' + pName + pIdent; cross = document.getElementById(name).firstChild.nodeValue; switch(cross) { case "--": cross = "\\\\"; break; case "\\\\": cross = "|"; break; case "|": cross = "/"; break; default: cross = "--"; break; } document.getElementById(name).firstChild.nodeValue = cross; } Expected result: ---------------- The same scripts, but insted of "name =..." there should be "var name = ..."

Comments

 [2006-09-13 16:15 UTC] farell (Laurent Laville)
When you said : "...that functions modify window.name property. In that case it can brake HTML links from working properly." Even if javascript write is not yet perfect (but it same state since the first version... a long time ago), could you give me a real example of such HTML braking links. And the full platform of test (OS, browser) Thanks in advance to reply to this feedback ! Laurent
 [2006-09-14 12:06 UTC] ipa at assis dot lt
It's to long to produce real example with HTML_Progress2 but i make a short one to ilustrate the problem which appears in the package using global name property: index.html ==================== <html> <body> <iframe name="frameWithProgress" src=""></iframe> <p><a href="http://www.google.com" target="frameWithProgress">Step 1. Shows that target works</a></p> <p><a href="progress.html" target="frameWithProgress">Step 2. Loading a page with progress</a></p> <p><a href="http://www.google.com" target="frameWithProgress">Step 3. Same as Step 1, A link must go to that iframe, but doesn't in IE and Opera. FF seems to works</a></p> </body> </html> progress.html ==================== <html> <body> <script> // Function contents doesn't matter, just setting the global name property function anyFunction() { name = 'anything'; } // we need only to run it anyFunction(); </script> I'm an example to brake the target (by changing window.name property) </body> </html>
 [2006-12-20 09:58 UTC] farell (Laurent Laville)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.