Try harder to get tag name from element

This could happen for any of the attributes, but for tagName this actually
happens in the wild... Since elem.tagName is equal to elem.nodeName we just try
to use this.

Fixes #2569
This commit is contained in:
Florian Bruhin 2017-04-28 14:28:28 +02:00
parent 06e317ac53
commit 513f83d446
2 changed files with 18 additions and 1 deletions

View File

@ -52,12 +52,20 @@ window._qutebrowser.webelem = (function() {
"id": id,
"text": elem.text,
"value": elem.value,
"tag_name": elem.tagName,
"outer_xml": elem.outerHTML,
"class_name": elem.className,
"rects": [], // Gets filled up later
};
// https://github.com/qutebrowser/qutebrowser/issues/2569
if (typeof elem.tagName === "string") {
out.tag_name = elem.tagName;
} else if (typeof elem.nodeName === "string") {
out.tag_name = elem.nodeName;
} else {
out.tag_name = "";
}
var attributes = {};
for (var i = 0; i < elem.attributes.length; ++i) {
var attr = elem.attributes[i];

View File

@ -726,3 +726,12 @@ Feature: Various utility commands.
Then no crash should happen
And the following tabs should be open:
- data/numbers/3.txt (active)
## Bugs
# https://github.com/qutebrowser/qutebrowser/issues/2569
Scenario: Clicking on form element with tagName child
When I open data/issue2569.html
And I run :click-element id theform
And I wait for "Clicked editable element!" in the log
Then no crash should happen