QwikDev / QwikDev/qwik

Solve the Google Translate problem in v2

Open
#7,461 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug V2
Dominant language
TypeScript
Stars
22.1k
Forks
1.4k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

Probably we should use some comments nodes for this


One of developer reported, that this code fixed problems with google translate in v2 (worth checking):

export const fix = () => {
    if (typeof Node !== "function" || !Node.prototype) {
        return;
    }

    const originalRemoveChild = Node.prototype.removeChild;
    const originalInsertBefore = Node.prototype.insertBefore;

    // @ts-expect-error
    Node.prototype.removeChild = function (child, ...rest) {
        if (child.parentNode !== this) {
            return child;
        }

        return originalRemoveChild.apply(this, [child, ...rest]);
    };

    // @ts-expect-error
    Node.prototype.insertBefore = function (newNode, referenceNode, ...rest) {
        if (referenceNode && referenceNode.parentNode !== this) {
            return newNode;
        }

        return originalInsertBefore.apply(this, [
            newNode,
            referenceNode,
            ...rest,
        ]);
    };
};

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test is named. Start by locating the v2 DOM update path and investigate how Google Translate interacts with node removal and insertion; compare that behavior with the proposed comment-node approach and Node.prototype guards. Done means the Google Translate problem is reproduced and resolved without breaking normal DOM updates.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.