fix: custom input for any element and mount query

This commit is contained in:
josc146
2023-03-20 09:21:31 +08:00
parent 47e56f962a
commit 47d4594e3d
2 changed files with 8 additions and 5 deletions
+7 -5
View File
@@ -23,9 +23,10 @@ async function mountComponent(siteConfig, userConfig) {
const retry = 10
for (let i = 1; i <= retry; i++) {
const e =
getPossibleElementByQuerySelector(siteConfig.sidebarContainerQuery) ||
getPossibleElementByQuerySelector(siteConfig.appendContainerQuery) ||
getPossibleElementByQuerySelector(siteConfig.resultsContainerQuery) ||
(siteConfig &&
(getPossibleElementByQuerySelector(siteConfig.sidebarContainerQuery) ||
getPossibleElementByQuerySelector(siteConfig.appendContainerQuery) ||
getPossibleElementByQuerySelector(siteConfig.resultsContainerQuery))) ||
getPossibleElementByQuerySelector([userConfig.prependQuery]) ||
getPossibleElementByQuerySelector([userConfig.appendQuery])
if (e) {
@@ -75,8 +76,9 @@ async function getInput(inputQuery) {
return input
}
const searchInput = getPossibleElementByQuerySelector(inputQuery)
if (searchInput && searchInput.value) {
return searchInput.value
if (searchInput) {
if (searchInput.value) return searchInput.value
else if (searchInput.textContent) return searchInput.textContent
}
}
@@ -1,4 +1,5 @@
export function getPossibleElementByQuerySelector(queryArray) {
if (!queryArray) return
for (const query of queryArray) {
if (query) {
try {