Skip to content

Commit

Permalink
Use native DOM manipulation more places (#4837)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsjohnsen authored and erikdesjardins committed Aug 28, 2018
1 parent 185f053 commit 37d5e38
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 15 deletions.
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);

This comment has been minimized.

Copy link
@kdreagle

kdreagle Sep 2, 2018

Contributor

This seems to be causing the tabs to appear as strings. I reverted the change in my local repo and it fixed the issue.
image

This comment has been minimized.

Copy link
@kevinji

kevinji Sep 2, 2018

Collaborator

Yeah, it's because gear is actually a string, not the actual HTML element. I believe tabMenuItem.after(string.html`${string.safe(gear)}`) should work.

}

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

0 comments on commit 37d5e38

Please sign in to comment.