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

Commit10f627a

Browse files
author
Mark Pilgrim
committed
added support for validating dir attribute
--HG--extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40979
1 parent32227cb commit10f627a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

‎src/html5lib/filters/validator.py‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
_(u"This value can not be blank: '%(attributeName)s' attribute on <%(tagName)s>."),
5050
"id-does-not-exist":
5151
_(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>."),
5254
"contextmenu-must-point-to-menu":
5355
_(u"The contextmenu attribute must point to an ID defined on a <menu> element."),
5456
})
@@ -358,8 +360,25 @@ def validateAttributeValueClass(self, token, tagName, attrName, attrValue):
358360
"attributeName":attrName}}
359361

360362
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
361375
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)}}
363382
yield {"type":"ParseError",
364383
"data":"invalid-attribute-value",
365384
"datavars": {"tagName":tagName,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp