Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use native DOM manipulation more places #4837

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use native DOM manipulation more places
  • Loading branch information
larsjohnsen committed Aug 28, 2018
commit fe2476459fa1e690a06fc158fdce49c5de7f46ea
2 changes: 1 addition & 1 deletion lib/modules/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function addTab(tabID: string, tabName: string, tabModuleId?: string): JQ
// if a module id has been provided then we automatically append the gear link
if (tabModuleId) {
const gear = SettingsNavigation.makeUrlHashLink(tabModuleId, undefined, ' ', 'gearIcon');
$(tabMenuItem).after(gear);
tabMenuItem.after(gear);
}

tabMenuItem.addEventListener('change', ({ detail: active }: any) => {
Expand Down
5 changes: 2 additions & 3 deletions lib/modules/filteReddit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import _ from 'lodash';
import { markdown } from 'snudown-js';
import { flow, filter, map, mapValues, keyBy, slice } from 'lodash/fp';
import { $ } from '../vendor';
import { Module } from '../core/module';
import * as Options from '../core/options';
import {
Expand Down Expand Up @@ -589,9 +588,9 @@ const createFilterline = _.once(({
filterline.createElement();

if (isPageType('comments')) {
$(filterline.element).insertBefore(document.querySelector('.comments-page .nestedlisting'));
document.querySelector('.comments-page .nestedlisting').before(filterline.element);
} else {
$(filterline.element).insertBefore(document.querySelector('#siteTable, .search-result-listing'));
document.querySelector('#siteTable, .search-result-listing').before(filterline.element);
}

BodyClasses.remove('res-filteReddit-filterline-pad-until-ready');
Expand Down
8 changes: 4 additions & 4 deletions lib/modules/keyboardNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -893,12 +893,12 @@ function updateLinkAnnotations(selected) {
number === 10 ? 'press 0 to open link' :
`press ${niceKeyCode(module.options.toggleCmdLine.value)} then ${number} and Enter to open link`;

const $annotation = $(string.html`<span class="noCtrlF keyNavAnnotation" data-text="[${number}]" title="${title}"></span>`);
const annotation = string.html`<span class="noCtrlF keyNavAnnotation" data-text="[${number}]" title="${title}"></span>`;

if (module.options.linkNumberPosition.value === 'right') $annotation.insertAfter(link);
else $annotation.insertBefore(link);
if (module.options.linkNumberPosition.value === 'right') link.after(annotation);
else link.before(annotation);

return { annotation: $annotation.get(0), link };
return { annotation, link };
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/neverEndingReddit.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function setLoaderWidgetActionText(widget) {

function attachLoaderWidget(widget) {
loaderWidget = widget;
$(siteTable()).after(widget);
siteTable().after(widget);

const prefetchIo = new IntersectionObserver(([{ isIntersecting }]) => {
if (!isIntersecting) return;
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/orangered.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const nativeButtons = _.once(() => {
if (!nativeInboxCount && (module.options.updateCurrentTab.value || module.options.updateOtherTabs.value)) {
nativeInboxCount = document.createElement('a');
nativeInboxCount.style.display = 'none';
$(nativeInboxButton).after(nativeInboxCount);
nativeInboxButton.after(nativeInboxCount);
}
return { nativeInboxButton, nativeInboxCount };
});
Expand Down
6 changes: 3 additions & 3 deletions lib/modules/showImages.js
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ async function checkElementForMedia(element) {

function placeExpando(expando, element, thing) {
if (!inText(element) && thing && thing.getTitleElement()) {
$(expando.button).insertAfter(element.parentElement);
element.parentElement.after(expando.button);
thing.entry.appendChild(expando.box);
} else {
$(element).add($(element).next('.keyNavAnnotation')).last()
Expand Down Expand Up @@ -1576,7 +1576,7 @@ function setMediaControls(media, lookupUrl, downloadUrl) {

const element = mediaControlsTemplate({ clippy: module.options.clippy.value, lookupUrl, downloadUrl, x, y });
const controls = element.querySelector('.res-media-controls');
$(media).replaceWith(element);
media.replaceWith(element);
element.appendChild(media);

media.classList.add('res-media-rotatable');
Expand Down Expand Up @@ -1855,7 +1855,7 @@ function makeMediaMovable(media: HTMLElement, element: HTMLElement, dragInitiate
function makeMediaIndependent(element: HTMLElement) {
const wrapper = document.createElement('div');
const independent = document.createElement('div');
$(element).replaceWith(wrapper);
element.replaceWith(wrapper);
wrapper.appendChild(independent);
independent.appendChild(element);

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/userInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ async function showUserInfo(card, username, thing) {
$body.on('click', '#ignoreUser', (e: Event) => {
if (e.target.classList.contains('blueButton')) userTag.ignore();
else userTag.unignore();
$(e.target).replaceWith(getButton());
e.target.replaceWith(getButton());
});

userHTML += getButton();
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/createElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function tabMenuItem({ text, aftercontent, className, title, checked, pre
</li>
`;

if (prepend) $(menu).prepend(element);
if (prepend) menu.prepend(element);
else menu.appendChild(element);

const a = element.querySelector('a');
Expand Down