Skip to content

Commit db90c03

Browse files
committed
Merge remote-tracking branch 'origin'
2 parents 6e988f7 + c66012a commit db90c03

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

django_unicorn/components/unicorn_template_response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ def get_root_element(soup: BeautifulSoup) -> Tag:
209209
for element in soup.contents:
210210
if isinstance(element, Tag) and element.name:
211211
if element.name == "html":
212-
view_element = element.find_next(attrs={"unicorn:view": True})
212+
view_element = element.find_next(
213+
attrs={"unicorn:view": True}
214+
) or element.find_next(attrs={"u:view": True})
213215

214216
if not view_element:
215217
raise MissingComponentViewElement(

tests/components/test_unicorn_template_response.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_get_root_element_no_element():
5050
assert str(actual) == expected
5151

5252

53-
def test_get_root_element_direct_view():
53+
def test_get_root_element_direct_view_unicorn():
5454
# Annoyingly beautifulsoup adds a blank string on the attribute
5555
expected = '<div unicorn:view="">test</div>'
5656

@@ -63,6 +63,17 @@ def test_get_root_element_direct_view():
6363
assert str(actual) == expected
6464

6565

66+
def test_get_root_element_direct_view_u():
67+
# Annoyingly beautifulsoup adds a blank string on the attribute
68+
expected = '<div u:view="">test</div>'
69+
70+
component_html = "<html><head></head>≤body><div u:view>test</div></body></html>"
71+
soup = BeautifulSoup(component_html, features="html.parser")
72+
actual = get_root_element(soup)
73+
74+
assert str(actual) == expected
75+
76+
6677
def test_get_root_element_direct_view_no_view():
6778
component_html = "<html><head></head>≤body><div>test</div></body></html>"
6879
soup = BeautifulSoup(component_html, features="html.parser")

0 commit comments

Comments
 (0)