Fixed issues with gridables proxy

This commit is contained in:
thepaperpilot 2021-06-26 11:47:44 -05:00
parent 273b9e0118
commit d2361bc444
2 changed files with 6 additions and 8 deletions

View file

@ -345,7 +345,7 @@ export function addLayer(layer, player = null) {
if (layer.grids[id].getStartData == undefined) { if (layer.grids[id].getStartData == undefined) {
layer.grids[id].getStartData = ""; layer.grids[id].getStartData = "";
} }
layer.grids[id].data = function(cell) { layer.grids[id].getData = function(cell) {
if (player[layer.id].grids[id][cell] != undefined) { if (player[layer.id].grids[id][cell] != undefined) {
return player[layer.id].grids[id][cell]; return player[layer.id].grids[id][cell];
} }

View file

@ -158,12 +158,12 @@ function getGridHandler(prefix) {
} else if (isFunction(target[key])) { } else if (isFunction(target[key])) {
const getterID = `${prefix}${key}`; const getterID = `${prefix}${key}`;
if (getterID in store.getters) { if (getterID in store.getters) {
return store.getters[getterID](); return store.getters[getterID];
} else { } else {
return target[key].bind(receiver); return target[key].bind(receiver);
} }
} }
if (!isNaN(key)) { if (typeof key !== 'symbol' && !isNaN(key)) {
target[key] = new Proxy(target, getCellHandler(key)); target[key] = new Proxy(target, getCellHandler(key));
} }
return target[key]; return target[key];
@ -187,9 +187,7 @@ function getCellHandler(id) {
} }
let prop = target[key]; let prop = target[key];
if (isFunction(prop)) { if (prop != undefined) {
return prop.call(receiver, id, target.data(id));
} else if (prop != undefined) {
return prop; return prop;
} }
@ -200,14 +198,14 @@ function getCellHandler(id) {
key = key.slice(0, 1).toUpperCase() + key.slice(1); key = key.slice(0, 1).toUpperCase() + key.slice(1);
prop = target[`get${key}`]; prop = target[`get${key}`];
if (isFunction(prop)) { if (isFunction(prop)) {
return prop.call(receiver, id, target.data(id)); return prop.call(receiver, id, target.getData(id));
} else if (prop != undefined) { } else if (prop != undefined) {
return prop; return prop;
} }
prop = target[`on${key}`]; prop = target[`on${key}`];
if (isFunction(prop)) { if (isFunction(prop)) {
return () => prop.call(receiver, id, target.data(id)); return () => prop.call(receiver, id, target.getData(id));
} else if (prop != undefined) { } else if (prop != undefined) {
return prop; return prop;
} }