Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit700a32a

Browse files
author
Mark Pilgrim
committed
added support for validating irrelevant attribute
--HG--extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40981
1 parent6510542 commit700a32a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎src/html5lib/filters/validator.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
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
defvalidateAttributeValueDraggable(self,token,tagName,attrName,attrValue):
369371
fortinself.checkEnumeratedValue(token,tagName,attrName,attrValue,frozenset(('true','false')))or []:yieldt
370372

373+
defvalidateAttributeValueIrrelevant(self,token,tagName,attrName,attrValue):
374+
fortinself.checkBooleanValue(token,tagName,attrName,attrValue)or []:yieldt
375+
371376
defcheckEnumeratedValue(self,token,tagName,attrName,attrValue,enumeratedValues):
372377
ifnotattrValueand (''notinenumeratedValues):
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+
defcheckBooleanValue(self,token,tagName,attrName,attrValue):
396+
enumeratedValues=frozenset((attrName,''))
397+
ifattrValuenotinenumeratedValues:
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
defvalidateAttributeValueContextmenu(self,token,tagName,attrName,attrValue):
391409
fortinself.checkIDValue(token,tagName,attrName,attrValue)or []:yieldt
392410
self.thingsThatPointToAnID.append(token)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp