From 513f83d44600479b24090e2ab50ef6b0ec459354 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 28 Apr 2017 14:28:28 +0200 Subject: [PATCH] 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 --- qutebrowser/javascript/webelem.js | 10 +++++++++- tests/end2end/features/misc.feature | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/qutebrowser/javascript/webelem.js b/qutebrowser/javascript/webelem.js index 206cdf129..749dfcc72 100644 --- a/qutebrowser/javascript/webelem.js +++ b/qutebrowser/javascript/webelem.js @@ -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]; diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature index 83de1c822..171fdf476 100644 --- a/tests/end2end/features/misc.feature +++ b/tests/end2end/features/misc.feature @@ -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