wix-style-react
Version:
35 lines (28 loc) • 985 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.extractDataAttributes = exports.extractAttributes = void 0;
var _filterObject = require("./filterObject");
/**
* a generic utility to get a subset of the received props object according to the prefix of the prop name
* @param props
* @param prefix
* @return {any}
*/
var extractAttributes = function extractAttributes(props) {
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return (0, _filterObject.filterObject)(props, function (key) {
return key.length >= prefix.length && key.indexOf(prefix) === 0;
});
};
/**
* Returns a subset of the received props object that starts with "data-"
* @param props
* @return {*}
*/
exports.extractAttributes = extractAttributes;
var extractDataAttributes = function extractDataAttributes(props) {
return extractAttributes(props, 'data-');
};
exports.extractDataAttributes = extractDataAttributes;