Skip to content

Commit

Permalink
Remove attribute for html5 compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
sterliakov authored and Andrzej Mateja committed Mar 23, 2022
1 parent f4d108b commit 5f425e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions phonenumber_field/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def __init__(self, initial=None):
super().__init__(choices=sorted(choices, key=lambda item: item[1]))

def get_context(self, name, value, attrs):
attrs = (attrs or {}).copy()
attrs.pop("maxlength", None)
return super().get_context(name, value or self.initial, attrs)


Expand Down
6 changes: 6 additions & 0 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def test_after_translation_deactivate_all(self):
'<select name="_0"><option value="" selected>---------</option>', rendered
)

def test_maxlength_not_in_select(self):
# Regression test for #490
widget = PhoneNumberPrefixWidget()
html = widget.render(name="widget", value=None, attrs={"maxlength": 32})
self.assertIn('<select name="widget_0">', html)


class PhoneNumberInternationalFallbackWidgetTest(SimpleTestCase):
def test_fallback_widget_switches_between_national_and_international(self):
Expand Down

0 comments on commit 5f425e6

Please sign in to comment.