Add the querySelectorSafe() function and replace querySelector() usage (#7380)

* Initial commit

* Correct the over-estimation of my abilities

* Add fallback and move code to dom.js

* Use new function for tm-focus-selector

* Replace other uses of querySelector*

* Undo rash replacements of querySelector()
This commit is contained in:
yaisog
2023-05-06 11:54:54 +01:00
committed by GitHub
parent 6820d45bf0
commit e92e125697
5 changed files with 27 additions and 11 deletions
+2 -6
View File
@@ -41,12 +41,8 @@ exports.startup = function() {
$tw.rootWidget.addEventListener("tm-focus-selector",function(event) {
var selector = event.param || "",
element,
doc = event.event && event.event.target ? event.event.target.ownerDocument : document;
try {
element = doc.querySelector(selector);
} catch(e) {
console.log("Error in selector: ",selector)
}
baseElement = event.event && event.event.target ? event.event.target.ownerDocument : document;
element = $tw.utils.querySelectorSafe(selector,baseElement);
if(element && element.focus) {
element.focus(event.paramObject);
}