-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
turbo isn't working with adsense #834
Comments
update - found the issue, the function doesNotTargetIFrame(anchor) |
the fix is simple, function doesNotTargetIFrame(anchor: HTMLAnchorElement): boolean { |
@eladmarg thank you for opening this issue. Making an implementation change seems straightforward, but making that change without a test case wouldn't prevent future changes to re-introduce a regression. Could you share some more information like an error stack trace or a JSFiddle with a minimum snippet of code to reproduce the behavior so that we can also include test coverage in the fix? |
sure, so simply add to the page an iframe of google ads this for instance:
then you'll see that its get selected when you click on another anchor element. |
Thank you for sharing that snippet! I've extracted the <iframe
frameborder="0"
src="https://5642dc6e614dd1d0e97dec6070467bae.safeframe.googlesyndication.com/safeframe/1-0-40/html/container.html"
id="google_ads_iframe_/4744526/ads_cat_top_desktop_0"
title="3rd party ad content"
name=""
scrolling="no"
marginwidth="0"
marginheight="0"
width="728" height="90"
data-is-safeframe="true"
sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation"
role="region"
aria-label="Advertisement"
tabindex="0"
data-google-container-id="1"
style="border: 0px; vertical-align: bottom;"
data-load-complete="true"></iframe> Note the name="" attribute. The presence of that attribute is at the root of the issue. I'll incorporate some tests into a pull request. |
awesome! thank you very much |
Closes [hotwired#834][] When applications embed [Google Adsense][]-powered `<iframe>` elements, the snippets they provide render them **with** a `[name]` attribute that's set to the empty string `""`: ```html <iframe frameborder="0" src="REDACTED" id="google_ads_iframe_/REDACTED" title="3rd party ad content" name="" scrolling="no" marginwidth="0" marginheight="0" width="728" height="90" data-is-safeframe="true" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" role="region" aria-label="Advertisement" tabindex="0" data-google-container-id="1" style="border: 0px; vertical-align: bottom;" data-load-complete="true"></iframe> ``` Note the `[name=""]` in the snippet. The guard clauses in the `FormSubmitObserver` and `LinkClickObserver` classes that prevent Turbo Drive from interfering with `<a>` clicks and `<form>` submissions that target `<iframe>` elements do not account for the presence of an `<iframe name="">`. This commit extends those guard clauses to first check for the presence of `a[target]`, `form[target]`, and `input[formtarget]` or `button[formtarget]` attributes before searching the document for an `iframe[name]` that matches. Additionally, it adds tests to cover a special-case scenario where there **is** an `iframe[name=""]` **and** an element that targets it (for example, `a[target=""]`). For example, consider the following example (along with a Turbo-less [JSFiddle][] that reproduces the behavior): ```html <iframe name=""></iframe> <a href="https://example.com" target="">Targets [name=""]</a> ``` When clicked, the `<a>` element drives the entire page. In our test suite, there are test cases that cover this behavior, and ensure that Turbo doesn't interfere in these scenarios. [Google Adsense]: https://www.google.com/adsense/start/ [hotwired#834]: hotwired#834 [JSFiddle]: https://jsfiddle.net/hk6587oz/
Closes [hotwired#834][] When applications embed [Google Adsense][]-powered `<iframe>` elements, the snippets they provide render them **with** a `[name]` attribute that's set to the empty string `""`: ```html <iframe frameborder="0" src="REDACTED" id="google_ads_iframe_/REDACTED" title="3rd party ad content" name="" scrolling="no" marginwidth="0" marginheight="0" width="728" height="90" data-is-safeframe="true" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" role="region" aria-label="Advertisement" tabindex="0" data-google-container-id="1" style="border: 0px; vertical-align: bottom;" data-load-complete="true"></iframe> ``` Note the `[name=""]` in the snippet. The guard clauses in the `FormSubmitObserver` and `LinkClickObserver` classes that prevent Turbo Drive from interfering with `<a>` clicks and `<form>` submissions that target `<iframe>` elements do not account for the presence of an `<iframe name="">`. This commit extends those guard clauses to first check for the presence of `a[target]`, `form[target]`, and `input[formtarget]` or `button[formtarget]` attributes before searching the document for an `iframe[name]` that matches. Additionally, it adds tests to cover a special-case scenario where there **is** an `iframe[name=""]` **and** an element that targets it (for example, `a[target=""]`). For example, consider the following example (along with a Turbo-less [JSFiddle][] that reproduces the behavior): ```html <iframe name=""></iframe> <a href="https://example.com" target="">Targets [name=""]</a> ``` When clicked, the `<a>` element drives the entire page. In our test suite, there are test cases that cover this behavior, and ensure that Turbo doesn't interfere in these scenarios. [Google Adsense]: https://www.google.com/adsense/start/ [hotwired#834]: hotwired#834 [JSFiddle]: https://jsfiddle.net/hk6587oz/
fixed. |
Closes [#834][] When applications embed [Google Adsense][]-powered `<iframe>` elements, the snippets they provide render them **with** a `[name]` attribute that's set to the empty string `""`: ```html <iframe frameborder="0" src="REDACTED" id="google_ads_iframe_/REDACTED" title="3rd party ad content" name="" scrolling="no" marginwidth="0" marginheight="0" width="728" height="90" data-is-safeframe="true" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" role="region" aria-label="Advertisement" tabindex="0" data-google-container-id="1" style="border: 0px; vertical-align: bottom;" data-load-complete="true"></iframe> ``` Note the `[name=""]` in the snippet. The guard clauses in the `FormSubmitObserver` and `LinkClickObserver` classes that prevent Turbo Drive from interfering with `<a>` clicks and `<form>` submissions that target `<iframe>` elements do not account for the presence of an `<iframe name="">`. This commit extends those guard clauses to first check for the presence of `a[target]`, `form[target]`, and `input[formtarget]` or `button[formtarget]` attributes before searching the document for an `iframe[name]` that matches. Additionally, it adds tests to cover a special-case scenario where there **is** an `iframe[name=""]` **and** an element that targets it (for example, `a[target=""]`). For example, consider the following example (along with a Turbo-less [JSFiddle][] that reproduces the behavior): ```html <iframe name=""></iframe> <a href="https://example.com" target="">Targets [name=""]</a> ``` When clicked, the `<a>` element drives the entire page. In our test suite, there are test cases that cover this behavior, and ensure that Turbo doesn't interfere in these scenarios. [Google Adsense]: https://www.google.com/adsense/start/ [#834]: #834 [JSFiddle]: https://jsfiddle.net/hk6587oz/
I didn't find the root cause for this issue, but if adsense on page, links aren't working with turbo.
(every link will trigger full page reload)
this start happen after 7.1 version (on 7.1 works ok, on 7.2-beta-1 or higher the problem exists).
if adsense isn't presenting, everything works as expected.
The text was updated successfully, but these errors were encountered: