forked from hotwired/turbo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR abstracts the FrameElement class into an anonymous class factory and matching interface type, permitting mixin to (almost) any element, and enabling registration of customized built-in elements as frames in addition to the standard autonomous custom element. Supports treating elements as a Turbo Frame that cannot otherwise carry one due to their content model, such as <tbody>. Set up with: Turbo.defineCustomFrameElement('tbody') and then use like: <table> <tbody id="tbody" is="turbo-frame-tbody"> <tr><td>Table content</td></tr> </tbody> </table> The response frame must match by the element name and both the is and id attributes. Implements: hotwired#48.
- Loading branch information
1 parent
f9d1651
commit 372c7a3
Showing
10 changed files
with
181 additions
and
81 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { FrameController } from "../core/frames/frame_controller" | ||
import { FrameElement } from "./frame_element" | ||
import { FrameElement, TurboFrameElement, builtinTurboFrameElement } from "./frame_element" | ||
import { StreamElement } from "./stream_element" | ||
|
||
FrameElement.delegateConstructor = FrameController | ||
|
||
export * from "./frame_element" | ||
export * from "./stream_element" | ||
|
||
customElements.define("turbo-frame", FrameElement) | ||
customElements.define("turbo-frame", TurboFrameElement) | ||
customElements.define("turbo-stream", StreamElement) | ||
|
||
export function defineCustomFrameElement(name: string) { | ||
customElements.define(`turbo-frame-${name}`, builtinTurboFrameElement(name), { extends: name }) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Frame</title> | ||
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script> | ||
</head> | ||
<body> | ||
<table> | ||
<tbody id="tbody0" is="turbo-frame-tbody"> | ||
<tr><td>Table service</td></tr> | ||
</tbody> | ||
</table> | ||
</body> | ||
</html> |
Oops, something went wrong.