Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Meta: Safer text node targeting - #6076

Merged
fregante merged 10 commits into
mainfrom
safer-replacement
Nov 4, 2022
Merged

fregante merged 10 commits into
mainfrom
safer-replacement

Conversation

@fregante

@fregante fregante commented Oct 12, 2022

Copy link
Copy Markdown
Member

Untested.

This should avoid future issues where the text nodes change position and we silently remove the wrong element.

Comment thread source/helpers/dom-utils.ts Outdated
fregante and others added 3 commits October 12, 2022 16:36
@fregante fregante added the meta Related to Refined GitHub itself label Oct 27, 2022
tagIcon.classList.add('mr-2');
// Remove whitespace node
tagIcon.nextSibling!.remove();
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be hit anymore. The only tag icon I see is green.

Screen Shot

cc @cheap-glitch from #3974

append: createBannerLink,
});
function initArchivedRepoBanner(signal: AbortSignal): void {
observe('[itemprop="name"] ~ .Label--attention', addLinkToBanner, {signal});

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a way to make this feature instant

// eslint-disable-next-line @typescript-eslint/ban-types -- Nodes may be exactly `null`
export const assertNodeContent = <N extends Text | ChildNode>(node: N | null, expectation: RegExp | string): N => {
if (!node || !(node instanceof Text)) {
console.warn('TypeError', node);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there was a way to attach data to errors and have the browser actually display it. error.PROP is basically inaccessible from the console, let alone visible

@fregante fregante changed the title Safer text replacement Meta: Safer text replacement Nov 4, 2022
@fregante fregante changed the title Meta: Safer text replacement Meta: Safer text node targeting Nov 4, 2022
@fregante
fregante marked this pull request as ready for review November 4, 2022 05:26
@fregante

fregante commented Nov 4, 2022

Copy link
Copy Markdown
Member Author

Everything tested. Merging 🚀

@fregante
fregante merged commit 075de6a into main Nov 4, 2022
@fregante
fregante deleted the safer-replacement branch November 4, 2022 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

2 participants