Sha256: 4a003d07af18258d4deebaa348b91de205f3356b11873270767711f34f47a982

Contents?: true

Size: 1.15 KB

Versions: 26

Compression:

Stored size: 1.15 KB

Contents

'use strict';

var isElementType = require('../misc/isElementType.js');

var maxLengthSupportedTypes;
(function(maxLengthSupportedTypes) {
    maxLengthSupportedTypes["email"] = "email";
    maxLengthSupportedTypes["password"] = "password";
    maxLengthSupportedTypes["search"] = "search";
    maxLengthSupportedTypes["telephone"] = "telephone";
    maxLengthSupportedTypes["text"] = "text";
    maxLengthSupportedTypes["url"] = "url";
})(maxLengthSupportedTypes || (maxLengthSupportedTypes = {}));
// can't use .maxLength property because of a jsdom bug:
// https://github.com/jsdom/jsdom/issues/2927
function getMaxLength(element) {
    var _element_getAttribute;
    const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== void 0 ? _element_getAttribute : '';
    return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;
}
function supportsMaxLength(element) {
    return isElementType.isElementType(element, 'textarea') || isElementType.isElementType(element, 'input') && element.type in maxLengthSupportedTypes;
}

exports.getMaxLength = getMaxLength;
exports.supportsMaxLength = supportsMaxLength;

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/cjs/utils/edit/maxLength.js