public
Last active

  • Download Gist
HTML5 input attribute core tests
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
attrTests: {
testAccept: function(_el) {
return !!(_el.accept === '') && !!(_el.accept !== 'undefined');
},
 
testAutocomplete: function(_el){
return !!(_el.autocomplete === '') && !!(_el.autocomplete !== 'undefined');
},
testAutofocus: function(_el){
return !!(_el.autofocus === false) && !!(_el.autofocus !== 'undefined');
},
testChecked: function(_el) {
return !!(_el.checked === false) && !!(_el.checekd !== 'undefined');
},
testList: function(_el){
return !!(typeof _el.list === 'object') && !!(_el.list !== 'undefined');
},
testMax: function(_el){
//feature test for validity object first
if (typeof _el.validity === 'object'){
return !!(_el.validity.rangeOverflow === 'false');
} else {
return false;
}
},
testMaxlength: function(_el) {
//webkit sets default maxlength to 524288, gecko and presto to -1
return (!!(_el.maxLength === -1) || !!(_el.maxLength === 524288)) && !!(_el.maxLength !== 'undefined');
},
testMin: function(_el) {
//feature test for validity object first
if (typeof _el.validity === 'object'){
return !!(_el.validity.rangeUnderflow === 'false');
} else {
return false;
}
},
testMultiple: function(_el) {
return (!!(_el.multiple === false) && !!(_el.list !== 'undefined'));
},
testPattern: function(_el) {
return !!(_el.pattern === '') && !!(_el.pattern !== 'undefined');
},
testPlaceholder: function(_el) {
return !!(_el.placeholder === '') && !!(_el.placeholder !== 'undefined');
},
testReadOnly: function(_el) {
return !!(_el.readOnly === false) && !!(_el.readOnly !== 'undefined');
},
testRequired: function(_el) {
return !!(_el.required === false) && !!(_el.required !== 'undefined');
},
testSize: function(_el) {
// webkit sets default size to 20, gecko and presto to 0
return (!!(_el.size === 0) || !!(_el.size === 20)) && !!(_text.size !== 'undefined');
},
testStep: function(_el) {
//feature test for validity object first
if (typeof _el.validity === 'object'){
return !!(_el.validity.stepMismatch === 'false');
} else {
return false;
}
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.