Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getProperty(context, propertyName, f = EMPTY_OBJECT) {
let objectState = f;
// Handle XVIZ v1 color override where our semantic color mapping
// differs from current OCS colors. In XVIZ v2 we should be aligned.
if (context.useSemanticColor) {
switch (propertyName) {
case 'stroke_color':
case 'fill_color':
objectState = XVIZObject.get(f.id) || f;
break;
default:
// ignore
}
}
// Handle XVIZ v1 style property name mismatches and
// setup validation function based on property name.
let altPropertyName = null;
switch (propertyName) {
case 'stroke_color':
case 'fill_color':
altPropertyName = 'color';
break;
export function setObjectState(objectStates, {stateName, id, value}) {
const state = {...objectStates[stateName]};
const xvizObject = XVIZObject.get(id);
if (xvizObject) {
xvizObject._setState(stateName, value);
}
if (value) {
state[id] = value;
} else {
delete state[id];
}
return {
...objectStates,
[stateName]: state
};
}