public
Created

bonsai.js bug reduction - running this script many times in a browser will behave differently

  • Download Gist
bug_reduction.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
<!doctype html>
<html lang="en" class=" -webkit-">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0;">
<title>Demo</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/bonsai/0.4.1/bonsai.min.js"></script>
</head>
 
<body>
<div id="movie1"></div>
<div id="movie2"></div>
</body>
 
<script>
var movie = bonsai.run(document.getElementById('movie1'), {
code: function() {
stage.on('message', function(data) {
new Rect(10, 10, 100, 100)
.fill('yellow')
.stroke('#f00', 2)
.addTo(stage);
});
},
width: 400,
height: 400,
});
 
var movie2 = bonsai.run(document.getElementById('movie2'), {
code: function(){},
width: 400,
height: 400,
});
 
movie2.on('load', function() {
movie.sendMessage({ foo: "bar" });
});
 
</script>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.