mirror of
https://github.com/django/django.git
synced 2024-11-29 22:56:46 +01:00
Fixed #30468 -- Fixed assertHTMLEqual() to handle all ASCII whitespace in a class attribute.
This commit is contained in:
parent
de6d3afb97
commit
b7a33ee4f0
@ -180,7 +180,7 @@ class Parser(HTMLParser):
|
||||
# Special case handling of 'class' attribute, so that comparisons of DOM
|
||||
# instances are not sensitive to ordering of classes.
|
||||
attrs = [
|
||||
(name, " ".join(sorted(value.split(" "))))
|
||||
(name, ' '.join(sorted(value for value in ASCII_WHITESPACE.split(value) if value)))
|
||||
if name == "class"
|
||||
else (name, value)
|
||||
for name, value in attrs
|
||||
|
@ -613,6 +613,20 @@ class HTMLEqualTests(SimpleTestCase):
|
||||
'<input type="text" id="id_name" />',
|
||||
'<input type="password" id="id_name" />')
|
||||
|
||||
def test_class_attribute(self):
|
||||
pairs = [
|
||||
('<p class="foo bar"></p>', '<p class="bar foo"></p>'),
|
||||
('<p class=" foo bar "></p>', '<p class="bar foo"></p>'),
|
||||
('<p class=" foo bar "></p>', '<p class="bar foo"></p>'),
|
||||
('<p class="foo\tbar"></p>', '<p class="bar foo"></p>'),
|
||||
('<p class="\tfoo\tbar\t"></p>', '<p class="bar foo"></p>'),
|
||||
('<p class="\t\t\tfoo\t\t\tbar\t\t\t"></p>', '<p class="bar foo"></p>'),
|
||||
('<p class="\t \nfoo \t\nbar\n\t "></p>', '<p class="bar foo"></p>'),
|
||||
]
|
||||
for html1, html2 in pairs:
|
||||
with self.subTest(html1):
|
||||
self.assertHTMLEqual(html1, html2)
|
||||
|
||||
def test_normalize_refs(self):
|
||||
pairs = [
|
||||
(''', '''),
|
||||
|
Loading…
Reference in New Issue
Block a user