51
51
_ (u"This value refers to a non-existent ID: '%(attributeName)s' attribute on <%(tagName)s>." ),
52
52
"invalid-enumerated-value" :
53
53
_ (u"Value must be one of %(enumeratedValues)s: '%(attributeName)s' attribute on <%tagName)s>." ),
54
+ "invalid-boolean-value" :
55
+ _ (u"Value must be one of %(enumeratedValues)s: '%(attributeName)s' attribute on <%tagName)s>." ),
54
56
"contextmenu-must-point-to-menu" :
55
57
_ (u"The contextmenu attribute must point to an ID defined on a <menu> element." ),
56
58
})
@@ -368,6 +370,9 @@ def validateAttributeValueDir(self, token, tagName, attrName, attrValue):
368
370
def validateAttributeValueDraggable (self , token , tagName , attrName , attrValue ):
369
371
for t in self .checkEnumeratedValue (token , tagName , attrName , attrValue , frozenset (('true' , 'false' ))) or []: yield t
370
372
373
+ def validateAttributeValueIrrelevant (self , token , tagName , attrName , attrValue ):
374
+ for t in self .checkBooleanValue (token , tagName , attrName , attrValue ) or []: yield t
375
+
371
376
def checkEnumeratedValue (self , token , tagName , attrName , attrValue , enumeratedValues ):
372
377
if not attrValue and ('' not in enumeratedValues ):
373
378
yield {"type" : "ParseError" ,
@@ -387,6 +392,19 @@ def checkEnumeratedValue(self, token, tagName, attrName, attrValue, enumeratedVa
387
392
"datavars" : {"tagName" : tagName ,
388
393
"attributeName" : attrName }}
389
394
395
+ def checkBooleanValue (self , token , tagName , attrName , attrValue ):
396
+ enumeratedValues = frozenset ((attrName , '' ))
397
+ if attrValue not in enumeratedValues :
398
+ yield {"type" : "ParseError" ,
399
+ "data" : "invalid-boolean-value" ,
400
+ "datavars" : {"tagName" : tagName ,
401
+ "attributeName" : attrName ,
402
+ "enumeratedValues" : tuple (enumeratedValues )}}
403
+ yield {"type" : "ParseError" ,
404
+ "data" : "invalid-attribute-value" ,
405
+ "datavars" : {"tagName" : tagName ,
406
+ "attributeName" : attrName }}
407
+
390
408
def validateAttributeValueContextmenu (self , token , tagName , attrName , attrValue ):
391
409
for t in self .checkIDValue (token , tagName , attrName , attrValue ) or []: yield t
392
410
self .thingsThatPointToAnID .append (token )
0 commit comments