Mercurial > p > roundup > code
changeset 5485:b0359a7c5b6d
create input elements with attributes in a defined (sorted) order
| author | Christof Meerwald <cmeerw@cmeerw.org> |
|---|---|
| date | Thu, 02 Aug 2018 20:56:01 +0100 |
| parents | ca8050fa5e78 |
| children | a5edd6adff14 |
| files | roundup/cgi/templating.py test/test_cgi.py test/test_templating.py |
| diffstat | 3 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/cgi/templating.py Thu Aug 02 19:56:28 2018 +0100 +++ b/roundup/cgi/templating.py Thu Aug 02 20:56:01 2018 +0100 @@ -444,7 +444,7 @@ def cgi_escape_attrs(**attrs): return ' '.join(['%s="%s"'%(k,cgi.escape(str(v), True)) - for k,v in attrs.items()]) + for k,v in sorted(attrs.items())]) def input_html4(**attrs): """Generate an 'input' (html4) element with given attributes"""
--- a/test/test_cgi.py Thu Aug 02 19:56:28 2018 +0100 +++ b/test/test_cgi.py Thu Aug 02 20:56:01 2018 +0100 @@ -801,7 +801,7 @@ <p>deferred</p> <p>admin, anonymous</p> <p></p> - <p><input type="text" name="superseder" value="5000" size="30"></p> + <p><input name="superseder" size="30" type="text" value="5000"></p> </body> </html> """.strip ())
--- a/test/test_templating.py Thu Aug 02 19:56:28 2018 +0100 +++ b/test/test_templating.py Thu Aug 02 20:56:01 2018 +0100 @@ -212,7 +212,7 @@ def test_string_field(self): p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with rouilj@example.com embedded < html</b>') - self.assertEqual(p.field(), '<input type="text" name="test1@test" value="A string <b> with rouilj@example.com embedded &lt; html</b>" size="30">') + self.assertEqual(p.field(), '<input name="test1@test" size="30" type="text" value="A string <b> with rouilj@example.com embedded &lt; html</b>">') def test_string_multiline(self): p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with rouilj@example.com embedded < html</b>')
