brackets-archive / bracketsIssues

Archive of issues in brackets.
0 stars 0 forks source link

[CLOSED] JavaScript not updating with live preview. #2872

Open core-ai-bot opened 3 years ago

core-ai-bot commented 3 years ago

Issue by ryansmith94 Wednesday Mar 06, 2013 at 20:24 GMT Originally opened as https://github.com/adobe/brackets/issues/3053


If you live preview a html file, any changes made to javascript that effect the loading of the page from this point on will not be changed in the live preview. Refreshing the browser has no effect. This worked as expected in Sprint 20, but not Sprint 21.

<!DOCTYPE html/>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <meta name="viewport" content="width=device-width">
    <title>Potential Brackets Sprint 21 Bug</title>
</head>
<body>
    <div id="box" style="width: 500px; height: 500px; background-color:green;"></div>
    <script type="text/javascript">
        // (1) Live preview to view this.
        // (2) Change the colour in the code below.
        // (3) Save and refresh the browser. Do not restart the live preview.
        // (4) You should see that the colour does not change.
        // (5) Restart the live preview and the colour changes.
        document.getElementById("box").style.backgroundColor = "#000000";
    </script>
</body>
</html>
core-ai-bot commented 3 years ago

Comment by ryansmith94 Wednesday Mar 06, 2013 at 20:29 GMT


That code in the issue is now working somehow... but I still get the issue in some other code so I'm going to try and figure out exactly what is going on.

core-ai-bot commented 3 years ago

Comment by ryansmith94 Wednesday Mar 06, 2013 at 20:41 GMT


Ok so I have an external script that I'm importing before my embedded script. When I live preview for the first time everything works as expected. Then I change a colour value (this is valid), I hit save and the page reloads incorrectly. When I check the console for errors I have a reference error because a variable from the external script is not defined and is used in my embedded script. I've checked the network tab in the dev tools and I can 100% confirm that the external script is there, but I can also confirm that the variable is not defined via the console. I'm going to try and make some new code to recreate the issue now.

core-ai-bot commented 3 years ago

Comment by ryansmith94 Wednesday Mar 06, 2013 at 21:21 GMT


Sorry about the wait. I've put the code that reproduces the problem below. However I should note that I've tested this with jQuery (and Prototype) instead of JSGL and the problem did not occur (this confusion is why it took so long), so I'm pretty much certain that the problem is caused by the fact that I'm getting the code from sourceforge because I haven't bothered to download the library yet while I'm testing.

<!DOCTYPE html/>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns:vml="urn:schemas-microsoft-com:vml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <meta name="viewport" content="width=device-width">
    <title>Potential Brackets Sprint 21 Bug</title>
</head>
<body>
    <div id="box" style="width: 500px; height: 500px; background-color:#A00;"></div>
    <script src="http://kent.dl.sourceforge.net/project/jsgraphicslib/jsgl%202.0/jsgl.min.js"></script>
    <script type="text/javascript">
        // Steps to reproduce the error.
        // (1) Live preview this.
        // (2) Change the colour code for green below.
        // (3) Hit save.
        // (4) Notice that the live preview is wrong.

        // If jsgl is defined make the box green.
        // Otherwise the box will be red.
        var colour = jsgl ? "#0A0" : "#A01";
        document.getElementById("box").style.backgroundColor = colour;
    </script>
</body>
</html>
core-ai-bot commented 3 years ago

Comment by peterflynn Thursday Mar 07, 2013 at 02:33 GMT


Hmm... I tried to reproduce this and it looks like the sourceforge URL is serving up HTML content instead of JS:

core-ai-bot commented 3 years ago

Comment by peterflynn Thursday Mar 07, 2013 at 02:36 GMT


If I download the file locally and reference that in the HTML, everything works as expected -- when I change the color and save it, the page auto-reloads and reflects the new color.

core-ai-bot commented 3 years ago

Comment by ryansmith94 Thursday Mar 07, 2013 at 08:00 GMT


Using the link to source forge you can view the HTML file in Chrome without using brackets and it works fine. The problem also doesn't occur in sprint 20 hence why I thought this was probably a bug, but I'm fairly satisfied with the conclusion that the problem is with source forge so feel free to close this.

core-ai-bot commented 3 years ago

Comment by njx Monday Mar 11, 2013 at 18:06 GMT


Sounds like we can close this.@ryansmith94, feel free to reopen if you think there's a real issue here. Thanks!