UNPKG

@rc-component/cascader

Version:
25 lines (24 loc) 792 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.warningNullOptions = warningNullOptions; var _util = require("@rc-component/util"); // value in Cascader options should not be null function warningNullOptions(options, fieldNames) { if (options) { const recursiveOptions = optionsList => { for (let i = 0; i < optionsList.length; i++) { const option = optionsList[i]; if (option[fieldNames?.value] === null) { (0, _util.warning)(false, '`value` in Cascader options should not be `null`.'); return true; } if (Array.isArray(option[fieldNames?.children]) && recursiveOptions(option[fieldNames?.children])) { return true; } } }; recursiveOptions(options); } }