Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 29x 29x 29x 29x 10x 29x 29x | import { CONSTANTS } from '../interface/exported';
/**
* @bindable
* helps get values in attibutes
*
*/
export function bindable(options?: any) {
// get passed in options
let _options: any;
_options = options;
return function (target: any, key: any) {
if (!target[CONSTANTS.META_BINDABLE]) {
target[CONSTANTS.META_BINDABLE] = {};
}
// replace uppercase with lower and add '-' for each one
const attribute = key.replace(/([a-z])([A-Z])/g, '$1-$2')
.replace(/\s+/g, '-')
.toLowerCase();
// check if attribute is added
if (options) {
if (!options.attribute) {
options.attribute = attribute;
}
}
// check if key is added, if not add
if (!target[CONSTANTS.META_BINDABLE][key]) {
target[CONSTANTS.META_BINDABLE][key] = {
key: key,
options: _options || {
attribute: attribute
}
};
}
};
}
|