gristlabs_grist-core/app/client/lib/domUtils.ts

17 lines
471 B
TypeScript
Raw Normal View History

import {useBindable} from 'app/common/gutil';
import {BindableValue, dom} from 'grainjs';
/**
* Version of makeTestId that can be appended conditionally.
*/
export function makeTestId(prefix: string) {
return (id: BindableValue<string>, obs?: BindableValue<boolean>) => {
return dom.cls(use => {
if (obs !== undefined && !useBindable(use, obs)) {
return '';
}
return `${useBindable(use, prefix)}${useBindable(use, id)}`;
});
};
}