diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-02-28 13:26:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-28 13:26:23 -0500 |
commit | fce2c51709852eea9dc14efe937537383e9c418d (patch) | |
tree | 4cb5ec9be9e424fd8f31c4a56afc63502c7afa39 | |
parent | f2d2ba0d25b6276d60001077573e30b60701a2d4 (diff) |
Add support for scanning the selected value of <select> elements (#1461)
-rw-r--r-- | ext/js/dom/document-util.js | 1 | ||||
-rw-r--r-- | ext/js/dom/text-source-element.js | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/ext/js/dom/document-util.js b/ext/js/dom/document-util.js index 80081aca..393ef294 100644 --- a/ext/js/dom/document-util.js +++ b/ext/js/dom/document-util.js @@ -36,6 +36,7 @@ class DocumentUtil { switch (element.nodeName.toUpperCase()) { case 'IMG': case 'BUTTON': + case 'SELECT': return new TextSourceElement(element); case 'INPUT': imposterSourceElement = element; diff --git a/ext/js/dom/text-source-element.js b/ext/js/dom/text-source-element.js index 45186636..1576bd5e 100644 --- a/ext/js/dom/text-source-element.js +++ b/ext/js/dom/text-source-element.js @@ -126,6 +126,13 @@ class TextSourceElement { case 'IMG': content = element.getAttribute('alt') || ''; break; + case 'SELECT': + { + const {selectedIndex, options} = element; + const option = (selectedIndex >= 0 && selectedIndex < options.length ? options[selectedIndex] : null); + content = (option !== null ? option.textContent : ''); + } + break; default: content = `${element.value}`; break; |