Skip to content

Commit

Permalink
Update to make compatible with jQuery
Browse files Browse the repository at this point in the history
This update fixes issues where the file would cause jQuery to break. 
This is in response to daleharvey#8 
For more info on the reason why it causes an issue - http://stackoverflow.com/questions/14941657/why-does-this-javascript-prototype-function-break-jquery
  • Loading branch information
dinc5150 authored Nov 25, 2016
1 parent 3acc5e2 commit 2a69993
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pacman.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ Pacman.Map = function (size) {
}

function reset() {
map = Pacman.MAP.clone();
map = cloneObj(Pacman.MAP);
height = map.length;
width = map[0].length;
};
Expand Down Expand Up @@ -1253,17 +1253,18 @@ Pacman.WALLS = [
{"line": [10.5, 9.5]}]
];

Object.prototype.clone = function () {
var i, newObj = (this instanceof Array) ? [] : {};
for (i in this) {
function cloneObj(obj) {
var i, newObj = (obj instanceof Array) ? [] : {};
for (var i in obj) {
if (i === 'clone') {
continue;
}
if (this[i] && typeof this[i] === "object") {
newObj[i] = this[i].clone();
if (obj[i] && typeof obj[i] === "object") {
newObj[i] = cloneObj(obj[i]);
} else {
newObj[i] = this[i];
newObj[i] = obj[i];
}
}
return newObj;
};

0 comments on commit 2a69993

Please sign in to comment.