|
49 | 49 | _(u"This value can not be blank: '%(attributeName)s' attribute on <%(tagName)s>."), |
50 | 50 | "id-does-not-exist": |
51 | 51 | _(u"This value refers to a non-existent ID: '%(attributeName)s' attribute on <%(tagName)s>."), |
| 52 | +"invalid-enumerated-value": |
| 53 | +_(u"Value must be one of %(enumeratedValues)s: '%(attributeName)s' attribute on <%tagName)s>."), |
52 | 54 | "contextmenu-must-point-to-menu": |
53 | 55 | _(u"The contextmenu attribute must point to an ID defined on a <menu> element."), |
54 | 56 | }) |
@@ -358,8 +360,25 @@ def validateAttributeValueClass(self, token, tagName, attrName, attrValue): |
358 | 360 | "attributeName":attrName}} |
359 | 361 |
|
360 | 362 | defvalidateAttributeValueContenteditable(self,token,tagName,attrName,attrValue): |
| 363 | +fortinself.checkEnumeratedValue(token,tagName,attrName,attrValue,frozenset(('true','false','')))or []:yieldt |
| 364 | + |
| 365 | +defvalidateAttributeValueDir(self,token,tagName,attrName,attrValue): |
| 366 | +fortinself.checkEnumeratedValue(token,tagName,attrName,attrValue,frozenset(('ltr','rtl')))or []:yieldt |
| 367 | + |
| 368 | +defcheckEnumeratedValue(self,token,tagName,attrName,attrValue,enumeratedValues): |
| 369 | +ifnotattrValueand (''notinenumeratedValues): |
| 370 | +yield {"type":"ParseError", |
| 371 | +"data":"attribute-value-can-not-be-blank", |
| 372 | +"datavars": {"tagName":tagName, |
| 373 | +"attributeName":attrName}} |
| 374 | +return |
361 | 375 | attrValue=attrValue.lower() |
362 | | -ifattrValuenotinfrozenset(('true','false','')): |
| 376 | +ifattrValuenotinenumeratedValues: |
| 377 | +yield {"type":"ParseError", |
| 378 | +"data":"invalid-enumerated-value", |
| 379 | +"datavars": {"tagName":tagName, |
| 380 | +"attributeName":attrName, |
| 381 | +"enumeratedValues":tuple(enumeratedValues)}} |
363 | 382 | yield {"type":"ParseError", |
364 | 383 | "data":"invalid-attribute-value", |
365 | 384 | "datavars": {"tagName":tagName, |
|