5151 _ (u"This value refers to a non-existent ID: '%(attributeName)s' attribute on <%(tagName)s>." ),
5252 "invalid-enumerated-value" :
5353 _ (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>." ),
5456 "contextmenu-must-point-to-menu" :
5557 _ (u"The contextmenu attribute must point to an ID defined on a <menu> element." ),
5658})
@@ -368,6 +370,9 @@ def validateAttributeValueDir(self, token, tagName, attrName, attrValue):
368370 def validateAttributeValueDraggable (self , token , tagName , attrName , attrValue ):
369371 for t in self .checkEnumeratedValue (token , tagName , attrName , attrValue , frozenset (('true' , 'false' ))) or []: yield t
370372
373+ def validateAttributeValueIrrelevant (self , token , tagName , attrName , attrValue ):
374+ for t in self .checkBooleanValue (token , tagName , attrName , attrValue ) or []: yield t
375+
371376 def checkEnumeratedValue (self , token , tagName , attrName , attrValue , enumeratedValues ):
372377 if not attrValue and ('' not in enumeratedValues ):
373378 yield {"type" : "ParseError" ,
@@ -387,6 +392,19 @@ def checkEnumeratedValue(self, token, tagName, attrName, attrValue, enumeratedVa
387392 "datavars" : {"tagName" : tagName ,
388393 "attributeName" : attrName }}
389394
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+
390408 def validateAttributeValueContextmenu (self , token , tagName , attrName , attrValue ):
391409 for t in self .checkIDValue (token , tagName , attrName , attrValue ) or []: yield t
392410 self .thingsThatPointToAnID .append (token )
0 commit comments