Skip to content

Commit

Permalink
Replace & selector with :scope for compatibility reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
aug-dev committed May 12, 2024
1 parent e93c3dd commit 1be863c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/scripts/search-engines/google-desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,10 @@ const desktopSerpHandlers: Record<string, SerpHandler> = {
const emptySlot =
textContainer.querySelector<HTMLElement>(".OpNfyc:empty");

let dateContainer =
textContainer.querySelector<HTMLElement>("& > div:last-child");
if (!dateContainer?.querySelector("& > span")) {
let dateContainer = textContainer.querySelector<HTMLElement>(
":scope > div:last-child",
);
if (!dateContainer?.querySelector(":scope > span")) {
dateContainer = null;
}

Expand All @@ -340,7 +341,7 @@ const desktopSerpHandlers: Record<string, SerpHandler> = {
zIndex: "1",
};
actionRoot.className = css(
actionRoot.matches("span + span, span > &")
actionRoot.matches("span + span, span > :scope")
? // Add a " · " separator to elements that come after a date
{
...commonStyle,
Expand Down Expand Up @@ -370,7 +371,7 @@ const desktopSerpHandlers: Record<string, SerpHandler> = {
}
// Copy container style in order to fit the action on Instagram posts that
// take all the available space.
if (actionRoot.matches(".OpNfyc > &")) {
if (actionRoot.matches(".OpNfyc > :scope")) {
actionRoot.classList.add("ryUkQc");
actionRoot.parentElement?.style.setProperty(
"background-color",
Expand Down

0 comments on commit 1be863c

Please sign in to comment.