diff --git a/src/lib/tools/scripts.cpp b/src/lib/tools/scripts.cpp index 529f037e8..150c304d5 100644 --- a/src/lib/tools/scripts.cpp +++ b/src/lib/tools/scripts.cpp @@ -131,10 +131,10 @@ QString Scripts::setupFormObserver() " registerForm(document.forms[i]);" "" "var observer = new MutationObserver(function(mutations) {" - " for (var i = 0; i < mutations.length; ++i)" - " for (var j = 0; j < mutations[i].addedNodes.length; ++j)" - " if (mutations[i].addedNodes[j].tagName == 'FORM')" - " registerForm(mutations[i].addedNodes[j]);" + " for (var mutation of mutations)" + " for (var node of mutation.addedNodes)" + " if (node.tagName && node.tagName.toLowerCase() == 'form')" + " registerForm(node);" "});" "observer.observe(document.documentElement, { childList: true, subtree: true });" "" @@ -303,11 +303,11 @@ QString Scripts::getFormData(const QPointF &pos) { QString source = QL1S("(function() {" "var e = document.elementFromPoint(%1, %2);" - "if (!e || e.tagName != 'INPUT')" + "if (!e || e.tagName.toLowerCase() != 'input')" " return;" "var fe = e.parentElement;" "while (fe) {" - " if (fe.tagName == 'FORM')" + " if (fe.tagName.toLowerCase() == 'form')" " break;" " fe = fe.parentElement;" "}" diff --git a/src/lib/webengine/webhittestresult.cpp b/src/lib/webengine/webhittestresult.cpp index a82def835..d4a894ce0 100644 --- a/src/lib/webengine/webhittestresult.cpp +++ b/src/lib/webengine/webhittestresult.cpp @@ -1,6 +1,6 @@ /* ============================================================ * Falkon - Qt web browser -* Copyright (C) 2015-2017 David Rosca +* Copyright (C) 2015-2018 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,12 +33,12 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos) "if (!e)" " return;" "function isMediaElement(e) {" - " return e.tagName == 'AUDIO' || e.tagName == 'VIDEO';" + " return e.tagName.toLowerCase() == 'audio' || e.tagName.toLowerCase() == 'video';" "}" "function isEditableElement(e) {" " if (e.isContentEditable)" " return true;" - " if (e.tagName == 'INPUT' || e.tagName == 'TEXTAREA')" + " if (e.tagName.toLowerCase() == 'input' || e.tagName.toLowerCase() == 'textarea')" " return e.getAttribute('readonly') != 'readonly';" " return false;" "}" @@ -62,16 +62,16 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos) "};" "var r = e.getBoundingClientRect();" "res.boundingRect = [r.top, r.left, r.width, r.height];" - "if (e.tagName == 'IMG')" + "if (e.tagName.toLowerCase() == 'img')" " res.imageUrl = e.getAttribute('src');" - "if (e.tagName == 'A') {" + "if (e.tagName.toLowerCase() == 'a') {" " res.linkTitle = e.text;" " res.linkUrl = e.getAttribute('href');" "}" "while (e) {" - " if (res.linkTitle == '' && e.tagName == 'A')" + " if (res.linkTitle == '' && e.tagName.toLowerCase() == 'a')" " res.linkTitle = e.text;" - " if (res.linkUrl == '' && e.tagName == 'A')" + " if (res.linkUrl == '' && e.tagName.toLowerCase() == 'a')" " res.linkUrl = e.getAttribute('href');" " if (res.mediaUrl == '' && isMediaElement(e)) {" " res.mediaUrl = e.currentSrc;"