From 1c73751fd9958e767f0b28831a25473bceef00f8 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 8 Aug 2016 14:11:01 +0200 Subject: [PATCH] Always lowercase tagName --- qutebrowser/browser/webelem.py | 11 +++++++---- qutebrowser/browser/webkit/webkitelem.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/qutebrowser/browser/webelem.py b/qutebrowser/browser/webelem.py index bd4bb20b4..8bb60d4ea 100644 --- a/qutebrowser/browser/webelem.py +++ b/qutebrowser/browser/webelem.py @@ -139,7 +139,10 @@ class AbstractWebElement(collections.abc.MutableMapping): raise NotImplementedError def tag_name(self): - """Get the tag name of this element.""" + """Get the tag name of this element. + + The returned name will always be lower-case. + """ raise NotImplementedError def outer_xml(self): @@ -299,7 +302,7 @@ class AbstractWebElement(collections.abc.MutableMapping): roles = ('combobox', 'textbox') log.misc.debug("Checking if element is editable: {}".format( repr(self))) - tag = self.tag_name().lower() + tag = self.tag_name() if self.is_content_editable() and self.is_writable(): return True elif self.get('role', None) in roles and self.is_writable(): @@ -321,7 +324,7 @@ class AbstractWebElement(collections.abc.MutableMapping): def is_text_input(self): """Check if this element is some kind of text box.""" roles = ('combobox', 'textbox') - tag = self.tag_name().lower() + tag = self.tag_name() return self.get('role', None) in roles or tag in ['input', 'textarea'] def remove_blank_target(self): @@ -330,7 +333,7 @@ class AbstractWebElement(collections.abc.MutableMapping): for _ in range(5): if elem is None: break - tag = elem.tag_name().lower() + tag = elem.tag_name() if tag == 'a' or tag == 'area': if elem.get('target', None) == '_blank': elem['target'] = '_top' diff --git a/qutebrowser/browser/webkit/webkitelem.py b/qutebrowser/browser/webkit/webkitelem.py index 71d0b9650..46f4fb8e9 100644 --- a/qutebrowser/browser/webkit/webkitelem.py +++ b/qutebrowser/browser/webkit/webkitelem.py @@ -134,7 +134,7 @@ class WebKitElement(webelem.AbstractWebElement): def tag_name(self): """Get the tag name for the current element.""" self._check_vanished() - return self._elem.tagName() + return self._elem.tagName().lower() def outer_xml(self): """Get the full HTML representation of this element."""