Fixed . in effect stat targets breaking entire sheet
This commit is contained in:
@@ -5,12 +5,16 @@ import computeVariableAsConstant from './computeVariable/computeVariableAsConsta
|
|||||||
import computeVariableAsClass from './computeVariable/computeVariableAsClass.js';
|
import computeVariableAsClass from './computeVariable/computeVariableAsClass.js';
|
||||||
import computeVariableAsToggle from './computeVariable/computeVariableAsToggle.js';
|
import computeVariableAsToggle from './computeVariable/computeVariableAsToggle.js';
|
||||||
import computeImplicitVariable from './computeVariable/computeImplicitVariable.js';
|
import computeImplicitVariable from './computeVariable/computeImplicitVariable.js';
|
||||||
|
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||||
|
|
||||||
export default function computeVariable(computation, node){
|
export default function computeVariable(computation, node){
|
||||||
const scope = computation.scope;
|
const scope = computation.scope;
|
||||||
if (!node.data) node.data = {};
|
if (!node.data) node.data = {};
|
||||||
aggregateLinks(computation, node);
|
aggregateLinks(computation, node);
|
||||||
combineAggregations(computation, node);
|
combineAggregations(computation, node);
|
||||||
|
// Don't add to the scope if the node id is not a legitimate variable name
|
||||||
|
// Without this `some.thing` could break the entire sheet as a database key
|
||||||
|
if (!VARIABLE_NAME_REGEX.test(node.id)) return;
|
||||||
if (node.data.definingProp){
|
if (node.data.definingProp){
|
||||||
// Add the defining variable to the scope
|
// Add the defining variable to the scope
|
||||||
scope[node.id] = node.data.definingProp
|
scope[node.id] = node.data.definingProp
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Must contain a letter, and be made of word characters only
|
// Must contain a letter, and be made of word characters only
|
||||||
const VARIABLE_NAME_REGEX = /^\w*[a-z]\w*$/i;
|
const VARIABLE_NAME_REGEX = /^[a-z][\w-]*$/i;
|
||||||
|
|
||||||
export default VARIABLE_NAME_REGEX;
|
export default VARIABLE_NAME_REGEX;
|
||||||
|
|||||||
Reference in New Issue
Block a user