-
Notifications
You must be signed in to change notification settings - Fork 439
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
Introduce FrameElement.getElementById(id: string)
#1136
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -163,9 +163,9 @@ export class Session { | |||||
const frameTarget = element.getAttribute("data-turbo-frame") | ||||||
const frame = frameTarget == "_top" ? | ||||||
null : | ||||||
document.getElementById(frameTarget) || findClosestRecursively(element, "turbo-frame:not([disabled])") | ||||||
FrameElement.getElementById(frameTarget) || findClosestRecursively(element, "turbo-frame") | ||||||
|
||||||
if (isUnsafe || isStream || frame instanceof FrameElement) { | ||||||
if (isUnsafe || isStream || (frame && !frame.disabled)) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sfnelson since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the sake of shrinking the diff, both of these lines could likely be reverted in part:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that looks fine. Would it make sense to add a static helper for finding the enclosing (non-disabled) FrameElement? In that case the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the purposes of code reuse, I can see two additional utility methods that would be helpful:
I think these would bring general utility to downstream consumers of Turbo – both of these cases have come up in our use of Frames to implement modals. |
||||||
return false | ||||||
} else { | ||||||
const location = new URL(element.href) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it could change the logic – e.g. a nested frame situation where the nearest frame is disabled.
In the old code, the nearest frame would be skipped and the outer frame returned, in the new logic nearest frame would be returned and the subsequent conditional would fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.