summaryrefslogtreecommitdiff
path: root/django/test/html.py
diff options
context:
space:
mode:
authorDavid Smith <smithdc@gmail.com>2023-07-05 06:51:29 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-07-14 10:25:00 +0200
commit1d0dfc0b920916900d2770f3b5640da08af36d97 (patch)
tree4989aae4e5faa3e04413161a7914237d7e323797 /django/test/html.py
parent6f1b8c00d8151059cc1902a92f067bbdc1673779 (diff)
Refs #30686 -- Moved Parser.SELF_CLOSING_TAGS to django.utils.html.VOID_ELEMENTS
Diffstat (limited to 'django/test/html.py')
-rw-r--r--django/test/html.py26
1 files changed, 3 insertions, 23 deletions
diff --git a/django/test/html.py b/django/test/html.py
index 87e213d651..6da79d6fb2 100644
--- a/django/test/html.py
+++ b/django/test/html.py
@@ -2,6 +2,7 @@
import html
from html.parser import HTMLParser
+from django.utils.html import VOID_ELEMENTS
from django.utils.regex_helper import _lazy_re_compile
# ASCII whitespace is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020
@@ -200,27 +201,6 @@ class HTMLParseError(Exception):
class Parser(HTMLParser):
- # https://html.spec.whatwg.org/#void-elements
- SELF_CLOSING_TAGS = {
- "area",
- "base",
- "br",
- "col",
- "embed",
- "hr",
- "img",
- "input",
- "link",
- "meta",
- "param",
- "source",
- "track",
- "wbr",
- # Deprecated tags
- "frame",
- "spacer",
- }
-
def __init__(self):
super().__init__()
self.root = RootElement()
@@ -248,14 +228,14 @@ class Parser(HTMLParser):
def handle_startendtag(self, tag, attrs):
self.handle_starttag(tag, attrs)
- if tag not in self.SELF_CLOSING_TAGS:
+ if tag not in VOID_ELEMENTS:
self.handle_endtag(tag)
def handle_starttag(self, tag, attrs):
attrs = normalize_attributes(attrs)
element = Element(tag, attrs)
self.current.append(element)
- if tag not in self.SELF_CLOSING_TAGS:
+ if tag not in VOID_ELEMENTS:
self.open_tags.append(element)
self.element_positions[element] = self.getpos()