forked from hotwired/turbo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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/
- Loading branch information
1 parent
2f0d46f
commit 6d39ceb
Showing
5 changed files
with
102 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters