diff options
author | 2019-02-13 14:23:03 +0800 | |
---|---|---|
committer | 2019-02-13 14:23:03 +0800 | |
commit | 7af18883aa400ab463d0c121be6fcf84c1cba142 (patch) | |
tree | cc1764cb4ee32e78fe0c7c8a6740514d8d97bd9f | |
parent | 38b53105f8ff8356140e80b49a7a85ca2e5589a2 (diff) | |
download | refined-github-7af18883aa400ab463d0c121be6fcf84c1cba142.tar.gz refined-github-7af18883aa400ab463d0c121be6fcf84c1cba142.tar.zst refined-github-7af18883aa400ab463d0c121be6fcf84c1cba142.zip |
Meta: Simplify select-dom usage
Thanks to https://github.com/bfred-it/select-dom/pull/5
-rw-r--r-- | package-lock.json | 6 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | source/features/branch-buttons.tsx | 2 | ||||
-rw-r--r-- | source/features/close-out-of-view-modals.tsx | 2 | ||||
-rw-r--r-- | source/features/copy-file.tsx | 4 | ||||
-rw-r--r-- | source/features/delete-fork-link.tsx | 2 | ||||
-rw-r--r-- | source/features/hide-empty-meta.tsx | 2 | ||||
-rw-r--r-- | source/features/hide-own-stars.tsx | 2 | ||||
-rw-r--r-- | source/features/hide-useless-comments.tsx | 2 | ||||
-rw-r--r-- | source/features/linkify-branch-refs.tsx | 4 | ||||
-rw-r--r-- | source/features/make-discussion-sidebar-sticky.tsx | 2 | ||||
-rw-r--r-- | source/features/pull-request-hotkey.tsx | 2 | ||||
-rw-r--r-- | source/libs/on-new-comments.ts | 4 |
13 files changed, 18 insertions, 18 deletions
diff --git a/package-lock.json b/package-lock.json index 344a5ec7..76e56f39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11047,9 +11047,9 @@ "dev": true }, "select-dom": { - "version": "4.2.0-3", - "resolved": "https://registry.npmjs.org/select-dom/-/select-dom-4.2.0-3.tgz", - "integrity": "sha512-YRQ6+F8IjcHx5LaIhrOB1WPFcHz9h46XfEm1RUpllgWwqwoe/l68IQ8ZIesFgKeq6uysZwXimGtsQ65MA8nUtA==" + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/select-dom/-/select-dom-4.2.1.tgz", + "integrity": "sha512-3QKsdTvd+IpWjabWgHh4upxdDipkD9YEOJ0czJDK3O5r95s25UQsRPe0H8JqfXa/MRD604N3wknFNtO6T8i//g==" }, "semver": { "version": "5.6.0", diff --git a/package.json b/package.json index afbf01b2..5ce2a83d 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "linkify-issues": "^1.3.0", "linkify-urls": "^2.2.0", "onetime": "^2.0.1", - "select-dom": "^4.2.0-3", + "select-dom": "^4.2.1", "shorten-repo-url": "^1.5.0", "storm-textarea": "2.0.1", "tiny-version-compare": "^0.10.0", diff --git a/source/features/branch-buttons.tsx b/source/features/branch-buttons.tsx index 88c0db72..3d0ec502 100644 --- a/source/features/branch-buttons.tsx +++ b/source/features/branch-buttons.tsx @@ -12,7 +12,7 @@ import {getRepoURL, getOwnerAndRepo} from '../libs/utils'; async function getTagLink() { const tags = select - .all<HTMLElement>('.branch-select-menu .select-menu-list:last-child .select-menu-item') + .all('.branch-select-menu .select-menu-list:last-child .select-menu-item') .map(element => element.dataset.name); if (tags.length === 0) { diff --git a/source/features/close-out-of-view-modals.tsx b/source/features/close-out-of-view-modals.tsx index f15d3837..0bf36908 100644 --- a/source/features/close-out-of-view-modals.tsx +++ b/source/features/close-out-of-view-modals.tsx @@ -5,7 +5,7 @@ import features from '../libs/features'; const observer = new IntersectionObserver(([{intersectionRatio, target}]) => { if (intersectionRatio === 0) { observer.unobserve(target); - const dropdown = select<HTMLElement>(` + const dropdown = select(` .dropdown-details[open] summary, body.menu-active .modal-backdrop `); diff --git a/source/features/copy-file.tsx b/source/features/copy-file.tsx index 3cff95ab..6e7a500f 100644 --- a/source/features/copy-file.tsx +++ b/source/features/copy-file.tsx @@ -6,11 +6,11 @@ import {groupSiblings} from '../libs/group-buttons'; function init() { // This selector skips binaries + markdowns with code - for (const code of select.all<HTMLElement>('.file .blob-wrapper > .highlight:not(.rgh-copy-file)')) { + for (const code of select.all('.file .blob-wrapper > .highlight:not(.rgh-copy-file)')) { code.classList.add('rgh-copy-file'); const file = code.closest('.file'); - const content = select.all<HTMLElement>('.blob-code-inner', file) + const content = select.all('.blob-code-inner', file) .map(blob => blob.innerText) .map(line => line === '\n' ? '' : line) .join('\n'); diff --git a/source/features/delete-fork-link.tsx b/source/features/delete-fork-link.tsx index 190141d6..e66f6d58 100644 --- a/source/features/delete-fork-link.tsx +++ b/source/features/delete-fork-link.tsx @@ -4,7 +4,7 @@ import features from '../libs/features'; import {getRepoURL} from '../libs/utils'; function init() { - const currentBranch = select<HTMLElement>('#partial-pull-merging .merge-branch-description .commit-ref'); + const currentBranch = select('#partial-pull-merging .merge-branch-description .commit-ref'); if (!currentBranch) { return false; } diff --git a/source/features/hide-empty-meta.tsx b/source/features/hide-empty-meta.tsx index ecc7bdc4..3c8fb542 100644 --- a/source/features/hide-empty-meta.tsx +++ b/source/features/hide-empty-meta.tsx @@ -2,7 +2,7 @@ import select from 'select-dom'; import features from '../libs/features'; function init() { - const meta = select<HTMLElement>('.repository-meta'); + const meta = select('.repository-meta'); if (select.exists('em', meta) && !select.exists('.js-edit-repo-meta-button')) { meta.style.display = 'none'; } diff --git a/source/features/hide-own-stars.tsx b/source/features/hide-own-stars.tsx index 2eecc3b8..56d2e49e 100644 --- a/source/features/hide-own-stars.tsx +++ b/source/features/hide-own-stars.tsx @@ -8,7 +8,7 @@ import {safeElementReady} from '../libs/dom-utils'; const observer = new MutationObserver(([{addedNodes}]) => { // Remove events from dashboard - for (const item of select.all<HTMLElement>('#dashboard .news .watch_started, #dashboard .news .fork')) { + for (const item of select.all('#dashboard .news .watch_started, #dashboard .news .fork')) { if (select(`a[href^="/${getUsername()}"]`, item)) { item.style.display = 'none'; } diff --git a/source/features/hide-useless-comments.tsx b/source/features/hide-useless-comments.tsx index a3a98f2a..2f0ede9a 100644 --- a/source/features/hide-useless-comments.tsx +++ b/source/features/hide-useless-comments.tsx @@ -46,7 +46,7 @@ function init() { } function unhide(event) { - for (const comment of select.all<HTMLElement>('.rgh-hidden-comment')) { + for (const comment of select.all('.rgh-hidden-comment')) { comment.hidden = false; } diff --git a/source/features/linkify-branch-refs.tsx b/source/features/linkify-branch-refs.tsx index 9a71134b..7451a7c9 100644 --- a/source/features/linkify-branch-refs.tsx +++ b/source/features/linkify-branch-refs.tsx @@ -17,7 +17,7 @@ function inPR() { // Find the URLs first, some elements don't have titles const urls = new Map<string, string>(); - for (const el of select.all<HTMLElement>('.commit-ref[title], .base-ref[title], .head-ref[title]')) { + for (const el of select.all('.commit-ref[title], .base-ref[title], .head-ref[title]')) { const [repo, branch] = el.title.split(':'); const branchName = el.textContent.trim(); urls.set( @@ -32,7 +32,7 @@ function inPR() { } } - for (const el of select.all<HTMLElement>('.commit-ref')) { + for (const el of select.all('.commit-ref')) { const branchName = el.textContent.trim(); if (branchName !== 'unknown repository') { diff --git a/source/features/make-discussion-sidebar-sticky.tsx b/source/features/make-discussion-sidebar-sticky.tsx index d346fe47..bf500213 100644 --- a/source/features/make-discussion-sidebar-sticky.tsx +++ b/source/features/make-discussion-sidebar-sticky.tsx @@ -5,7 +5,7 @@ import debounce from 'debounce-fn'; import features from '../libs/features'; function updateStickiness() { - const sidebar = select<HTMLElement>('.discussion-sidebar'); + const sidebar = select('.discussion-sidebar'); const sidebarHeight = sidebar.offsetHeight + 25 + 60; // 60 matches sticky header's height sidebar.classList.toggle('rgh-sticky-sidebar', sidebarHeight < window.innerHeight); } diff --git a/source/features/pull-request-hotkey.tsx b/source/features/pull-request-hotkey.tsx index 28786f34..6b84f564 100644 --- a/source/features/pull-request-hotkey.tsx +++ b/source/features/pull-request-hotkey.tsx @@ -2,7 +2,7 @@ import select from 'select-dom'; import features from '../libs/features'; function init() { - const tabs = select.all<HTMLElement>('.tabnav-pr .tabnav-tab'); + const tabs = select.all('.tabnav-pr .tabnav-tab'); const selectedIndex = tabs.indexOf(select('.tabnav-pr .selected')); const lastTab = tabs.length - 1; diff --git a/source/libs/on-new-comments.ts b/source/libs/on-new-comments.ts index 9f5b98f1..8b439cf7 100644 --- a/source/libs/on-new-comments.ts +++ b/source/libs/on-new-comments.ts @@ -3,7 +3,7 @@ import debounce from 'debounce-fn'; import observeEl from './simplified-element-observer'; const handlers = new Set<() => void>(); -const observed = new WeakSet<HTMLElement>(); +const observed = new WeakSet(); const run = debounce(() => { // Safely run all callbacks @@ -25,7 +25,7 @@ const addListenersOnNewElements = debounce(() => { }, {wait: 50}); const setup = () => { - const discussion = select<HTMLElement>('.js-discussion'); + const discussion = select('.js-discussion'); if (!discussion || observed.has(discussion)) { return; } |