File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
django_unicorn/components Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff 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+
6677def 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" )
You can’t perform that action at this time.
0 commit comments