-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure we always render errors with the Append strategy (#134)
## New Features * Better error handling to help developers * Better abort handling to help developers * Switch to Rack middleware ingress/egress for commands * Revamp state management * Add page state tracking and restoration ## Improvements and Fixes * Ensure finish event is dispatched on abort/error * Add more tests * Get optimistic state restoration working reliably * Switch to localStorage so state persists across tabs
- Loading branch information
Showing
68 changed files
with
1,635 additions
and
682 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
ruby_version: 2.7 | ||
ruby_version: 3.0 | ||
format: progress | ||
parallel: true | ||
|
||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,18 +1,24 @@ | ||
import uuids from './uuids' | ||
|
||
const append = content => { | ||
document.body.insertAdjacentHTML('beforeend', content) | ||
} | ||
|
||
const replace = content => { | ||
const parser = new DOMParser() | ||
const doc = parser.parseFromString(content, 'text/html') | ||
TurboBoost.Streams.morph.method(document.documentElement, doc.documentElement) | ||
const head = document.querySelector('head') | ||
const body = document.querySelector('body') | ||
const newHead = doc.querySelector('head') | ||
const newBody = doc.querySelector('body') | ||
if (head && newHead) TurboBoost?.Streams?.morph?.method(head, newHead) | ||
if (body && newBody) TurboBoost?.Streams?.morph?.method(body, newBody) | ||
} | ||
|
||
// TODO: dispatch events after append/replace so we can apply page state | ||
export const render = (strategy, content) => { | ||
if (strategy.match(/^Append$/i)) return append(content) | ||
if (strategy.match(/^Replace$/i)) return replace(content) | ||
if (strategy && content) { | ||
if (strategy.match(/^Append$/i)) return append(content) | ||
if (strategy.match(/^Replace$/i)) return replace(content) | ||
} | ||
} | ||
|
||
export default { render } |
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
Oops, something went wrong.