At the moment, a shadow DOM search is performed for matching inputs with the same name or value. This type of search could be extended to any DOM element with the same matching value in a shadow DOM.
|
function replaceInInputShadow( |
|
input: HTMLInputElement | HTMLTextAreaElement, |
|
config: SearchReplaceConfig, |
|
newValue: string |
|
) { |
|
if (config.shadowRoots.length) { |
|
config.shadowRoots.map((shadowRoot) => { |
|
let shadowInputs = Array.from(shadowRoot.querySelectorAll(`input[id="${input['id']}"]`)) |
|
if (!shadowInputs.length) { |
|
shadowInputs = Array.from(shadowRoot.querySelectorAll(`input[name="${input['name']}"]`)) |
|
} |
|
if (!shadowInputs.length) { |
|
shadowInputs = Array.from(shadowRoot.querySelectorAll(`input[value="${input['value']}"]`)) |
|
} |
|
if (!shadowInputs.length) { |
|
// perform less exact search |
|
shadowInputs = Array.from(shadowRoot.querySelectorAll(`*[value="${input['value']}"]`)) |
|
} |
|
if (shadowInputs.length) { |
|
shadowInputs.map((shadowInput) => { |
|
shadowInput['value'] = newValue |
|
shadowInput.dispatchEvent(new Event('input', { bubbles: true })) |
|
}) |
|
shadowRoot.host.dispatchEvent(new Event('input', { bubbles: true })) |
|
} |
|
}) |
|
} |
|
} |
At the moment, a shadow DOM search is performed for matching inputs with the same name or value. This type of search could be extended to any DOM element with the same matching value in a shadow DOM.
search-replace/src/searchreplace.ts
Lines 75 to 102 in a5df325