event handler depend on attribute of element break by translation
Reported by
shie...@kkvesper.jp,
May 25 2016
|
|||||||||||||||||
Issue descriptionChrome Version : 50.0.2661.102 (Official Build) m (64-bit) URLs (if applicable) : https://www.tablesolution.com/ Other browsers tested: n/a What steps will reproduce the problem? (1) Visit https://www.tablesolution.com/ The page text is in Japanese (2) In Chrome menu, choose "Translate this page" to English (3) Click on the "YES" or "NO" links at top. What is the expected result? Click "YES", you should navigate to https://www.tablesolution.com/en Click "NO", nothing should happen (javascript: void(0) set on link). What happens instead? For both YES and NO, browser navigates to https://www.tablesolution.com/undefined Please provide any additional information below. Attach a screenshot if possible.
,
May 25 2016
,
May 25 2016
I can't reproduce this on Linux with v50.0.2661.102. As far as I am aware, we don't automatically navigate on translate completion. We do send messages to the JavaScript layer about language detection and translation events, and in principle it might be somehow possible for the site developers to hook into these and try to navigate on behalf of the user: https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/resources/translate_internals/translate_internals.js I don't see anything obvious in the handler c++ code that would indicate any kind of automatic navigation: https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc Do you have any plugins installed that might be causing this behaviour?
,
May 25 2016
We've reproduced this on both Windows and Mac (two separate machines) so I doubt it's plugin related. Here's screen-by-screen to reproduce, please confirm you've followed exactly:
,
May 25 2016
Sorry, I misunderstood the original entry. Yes, this reproduces for me now. This looks like a problem with the "locale-select" logic in the page, which is obfuscated and minified and is best left to the page authors to debug. It seems likely that the javascript tries to get locale information out of a mapping it maintains internally and navigate to the right URL. I'd suggest digging into that logic to figure out what the mapping information is and how it is bound/read. If you find that something in the browser's language information as exposed to the Javascript API is broken, that is something we can investigate; but it's equally likely at this point that it's a bug in the developer's script that is managing this transition.
,
May 25 2016
PS - If your mapping is kept around in plain-text, like in a hidden div, it is entirely possible that the text is being translated. AFAIK translate should not touch any <script> blocks at all, nor should it translate href attributes etc.
,
May 25 2016
Hi Andrew thanks for investigating this.
Here's the relevant coffeescript for this (I'm the owner of the page)
$('.locale-select').click (event)=>
event.preventDefault()
$target = @$(event.target)
@storeLocale($target.data('locale'))
window.location = $target.attr('href')
The problem is that $target.attr('href') is returning undefined; this only happens AFTER Chrome translate.
$target.prop('href') gives the same result.
,
May 25 2016
OK this seems to work:
$('.locale-select').click (event)->
event.preventDefault()
$target = LocaleDetect.$(@)
LocaleDetect.storeLocale($target.data('locale'))
window.location = $target.attr('href')
I guess Chrome Translate breaks jQuery's event.target?
,
May 25 2016
Tested in win7, win10 & OSX 10.11.5 on stable version 51.0.2704.63 m. Looks issue fixed. when click on "YES" navigating https://www.tablesolution.com/en/index.html when click on "NO" nothing happend. Thank you.
,
May 25 2016
@mummare...@chromium.org Actually I applied the workaround to the page. The bug still exists in Chrome. Here is a generic description: 1) If I have any element that contains translatable text 2) AND I add a jQuery event listener to that element, and the callback function references event.target 3) AND I click "Translate to English..." in Chrome 4) THEN when the callback function fires, any attempt to do $(event.target).attr('xxx') (where xxx is any HTML attribute) will return undefined. As a workaround, calling $(this) instead of $(event.target) will allow you to fetch the data.
,
May 25 2016
Got it, thanks for the clarification.
,
May 26 2016
This might not be a bug in Chrome as such, but perhaps a side effect of the way that translation works. IIRC a script is downloaded from the Google Translate servers and it goes through and modifies the page content; it's conceivable that those modifications mess with the DOM elements in a way that makes jquery unhappy in this specific case (or more generally). My expertise here is on how language detection functions. Kenji, do you know who would be a better person to loop in on this?
,
May 26 2016
,
Jun 2 2016
We've just received a suspiciously similar report in issue 616744 saying that translate is altering CSS.
,
Jun 24 2016
Removing myself since I don't work on Translate anymore.
,
Jun 29 2016
The code change need to from Google Translate Element. Internal bug id is 29872734
,
Jun 29 2016
rename this bug to "event handler depend on attribute of element break by translation"
Simplified example to show the problem
<html>
<body>
<span id=id1 love=good>text</span>
<script>
function myclick(event) {
event.preventDefault();
document.write("event.target: " + event.target.getAttribute("love") + "<br>");
document.write("event.currentTarget: " + event.currentTarget.getAttribute("love") + "<br>");
document.write("this: " + this.getAttribute("love") + "<br>");
return true;
}
document.getElementById("id1").onclick=myclick;
</script>
</body>
</html>
,
Jun 29 2016
,
Jul 8 2016
Moving this nonessential bug to the next milestone. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Apr 17 2017
,
Apr 17 2017
,
Apr 18 2017
,
Apr 18 2017
,
Apr 27 2017
,
Aug 11 2017
,
Sep 26 2017
,
Jan 18 2018
,
Mar 7 2018
|
|||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||
Comment 1 by tkonch...@chromium.org
, May 25 2016Components: UI>Browser>Translate
Labels: M-53
Status: Untriaged (was: Unconfirmed)