Skip to content

Commit 8290e0d

Browse files
authored
Merge pull request #5824 from davepagurek/fix/setattributes
Make sure setAttributes updates lingering references to the old canvas
2 parents 387a509 + 14ed204 commit 8290e0d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/webgl/p5.RendererGL.js

+1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ p5.RendererGL.prototype._resetContext = function(options, callback) {
297297
document.body.appendChild(c);
298298
}
299299
this._pInst.canvas = c;
300+
this.canvas = c;
300301
}
301302

302303
const renderer = new p5.RendererGL(

test/unit/webgl/p5.RendererGL.js

+11
Original file line numberDiff line numberDiff line change
@@ -756,4 +756,15 @@ suite('p5.RendererGL', function() {
756756
done();
757757
});
758758
});
759+
760+
suite('setAttributes', function() {
761+
test('It leaves a reference to the correct canvas', function(done) {
762+
const renderer = myp5.createCanvas(10, 10, myp5.WEBGL);
763+
assert.equal(myp5.canvas, renderer.canvas);
764+
765+
myp5.setAttributes({ alpha: true });
766+
assert.equal(myp5.canvas, renderer.canvas);
767+
done();
768+
});
769+
});
759770
});

0 commit comments

Comments
 (0)