|
8 | 8 | */
|
9 | 9 | (function( factory ) {
|
10 | 10 | if ( typeof define === "function" && define.amd ) {
|
11 |
| - define( ["jquery"], factory ); |
| 11 | + define( ["jquery", "jquery/jquery.metadata"], factory ); |
12 | 12 | } else if (typeof module === "object" && module.exports) {
|
13 | 13 | module.exports = factory( require( "jquery" ) );
|
14 | 14 | } else {
|
|
192 | 192 | data = $.validator.normalizeRules(
|
193 | 193 | $.extend(
|
194 | 194 | {},
|
| 195 | + $.validator.metadataRules(element), |
195 | 196 | $.validator.classRules( element ),
|
196 | 197 | $.validator.attributeRules( element ),
|
197 | 198 | $.validator.dataRules( element ),
|
|
782 | 783 | normalizer = this.settings.normalizer;
|
783 | 784 | }
|
784 | 785 |
|
785 |
| - // If normalizer is defined, then call it to the changed value instead |
| 786 | + // If normalizer is defined, then call it to retreive the changed value instead |
786 | 787 | // of using the real one.
|
787 | 788 | // Note that `this` in the normalizer is `element`.
|
788 | 789 | if ( normalizer ) {
|
|
1038 | 1039 | // 'aria-describedby' should directly reference the error element
|
1039 | 1040 | if ( describer ) {
|
1040 | 1041 | selector = selector + ", #" + this.escapeCssMeta( describer )
|
1041 |
| - .replace( /\s+/g, ", #" ); |
| 1042 | + .replace( /\s+/g, ", #" ) + ":visible"; |
1042 | 1043 | }
|
1043 | 1044 |
|
1044 | 1045 | return this
|
|
1240 | 1241 | }
|
1241 | 1242 | },
|
1242 | 1243 |
|
| 1244 | + metadataRules: function (element) { |
| 1245 | + if (!$.metadata) { |
| 1246 | + return {}; |
| 1247 | + } |
| 1248 | + |
| 1249 | + var meta = $.data(element.form, 'validator').settings.meta; |
| 1250 | + return meta ? |
| 1251 | + $(element).metadata()[meta] : |
| 1252 | + $(element).metadata(); |
| 1253 | + }, |
| 1254 | + |
1243 | 1255 | attributeRules: function( element ) {
|
1244 | 1256 | var rules = {},
|
1245 | 1257 | $element = $( element ),
|
|
0 commit comments