preact icon indicating copy to clipboard operation
preact copied to clipboard

conflict with page translation code(like google translate)

Open baofuno1 opened this issue 3 years ago • 1 comments

version: 10.10.0

I read through the issues and found these two issues, but still haven't found any solution, the patch will affect other functions of the page and it doesn't seem to take effect.

https://github.com/preactjs/preact/issues/948 https://github.com/preactjs/preact/issues/3078

I tried using this patch,but its not work https://gist.github.com/developit/3e807962630ddbd4977cbd07b597f24f#file-preact-google-translate-patch-js-L54

Is there any solution to this problem so far? I thought about it for a long time without thinking about it. expecting a reply

The official website also has the same problem image

baofuno1 avatar Jul 21 '22 08:07 baofuno1

My English is limited so I used translation software, I hope you can understand, lol

baofuno1 avatar Jul 21 '22 08:07 baofuno1

This patch should work:

var insertBefore = Element.prototype.insertBefore;
Element.prototype.insertBefore = function(node, before) {
  if (node instanceof Text && before instanceof HTMLElement && before.localName === 'font') {
    return node;
  }
  return insertBefore.call(this, node, before);
};

developit avatar Oct 03 '22 00:10 developit