non-empty-if-present-evaluate.js 529 B

12345678910111213141516171819
  1. function nonEmptyIfPresentEvaluate(node, options, virtualNode) {
  2. // Check for 'default' names, which are given to reset and submit buttons
  3. const nodeName = virtualNode.props.nodeName;
  4. const type = (virtualNode.attr('type') || '').toLowerCase();
  5. const label = virtualNode.attr('value');
  6. if (label) {
  7. this.data({
  8. messageKey: 'has-label'
  9. });
  10. }
  11. if (nodeName === 'input' && ['submit', 'reset'].includes(type)) {
  12. return label === null;
  13. }
  14. return false;
  15. }
  16. export default nonEmptyIfPresentEvaluate;