NativeRestriction.js
25 lines
| 1 | import Restriction from './Restriction'; |
| 2 | |
| 3 | function NativeRestriction() { |
| 4 | Restriction.call( this ); |
| 5 | |
| 6 | this.isSupported = function ( node, reporting ) { |
| 7 | return !!node.checkValidity; |
| 8 | }; |
| 9 | |
| 10 | this.validate = function () { |
| 11 | const { nodes } = this.reporting.input; |
| 12 | |
| 13 | for ( const node of nodes ) { |
| 14 | if ( node.checkValidity() ) { |
| 15 | return true; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | return false; |
| 20 | }; |
| 21 | } |
| 22 | |
| 23 | NativeRestriction.prototype = Object.create( Restriction.prototype ); |
| 24 | |
| 25 | export default NativeRestriction; |