Skip to content

Commit 77b929d

Browse files
author
lauren mccarthy
committed
fixing attachment of objects on global mode
1 parent a4c4bd1 commit 77b929d

File tree

3 files changed

+41
-21
lines changed

3 files changed

+41
-21
lines changed

lib/p5.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! p5.js v0.3.3 August 22, 2014 */
1+
/*! p5.js v0.3.3 August 25, 2014 */
22
var shim = function (require) {
33
window.requestDraw = function () {
44
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) {
@@ -247,11 +247,18 @@ var core = function (require, shim, constants) {
247247
}
248248
});
249249
if (this._isGlobal) {
250-
for (var p in p5.prototype) {
250+
for (var p0 in p5.prototype) {
251251
try {
252-
delete window[p];
252+
delete window[p0];
253253
} catch (x) {
254-
window[p] = undefined;
254+
window[p0] = undefined;
255+
}
256+
}
257+
for (var p1 in p5) {
258+
try {
259+
delete window[p1];
260+
} catch (x) {
261+
window[p1] = undefined;
255262
}
256263
}
257264
for (var p2 in this) {
@@ -271,16 +278,19 @@ var core = function (require, shim, constants) {
271278
}
272279
if (!sketch) {
273280
this._isGlobal = true;
274-
for (var p in p5.prototype) {
275-
if (typeof p5.prototype[p] === 'function') {
276-
var ev = p.substring(2);
281+
for (var p0 in p5.prototype) {
282+
if (typeof p5.prototype[p0] === 'function') {
283+
var ev = p0.substring(2);
277284
if (!this._events.hasOwnProperty(ev)) {
278-
window[p] = p5.prototype[p].bind(this);
285+
window[p0] = p5.prototype[p0].bind(this);
279286
}
280287
} else {
281-
window[p] = p5.prototype[p];
288+
window[p0] = p5.prototype[p0];
282289
}
283290
}
291+
for (var p1 in p5) {
292+
window[p1] = p5[p1];
293+
}
284294
for (var p2 in this) {
285295
if (this.hasOwnProperty(p2)) {
286296
window[p2] = this[p2];

0 commit comments

Comments
 (0)