Repository navigation
[lexical-clipboard][lexical-website] Feature: Allow clipboard import middleware to replace data and selection - #9312
Conversation
… to replace data and selection
## Description
Clipboard import middleware currently delegates through a zero-argument `$next` callback, so every handler receives the original data and selection.
Allow `$next(data?, selection?)` to replace either argument for the remaining handlers in that MIME-type stack. Each callback defaults to the arguments received by its handler, making `$next()` equivalent to `$next(data, selection)` even after earlier middleware replaces them. Preserve the original DataTransfer.
Update the TypeScript signature, Flow declaration, and clipboard import documentation. Cover data and selection replacements, empty strings, forwarding through multiple handlers, and insertion by the default importer.
## Test plan
### Before
With the regression tests added, before changing the stack runner:
`pnpm exec vitest run --project unit packages/lexical-clipboard/src/__tests__/unit/ClipboardImportExtension.test.ts`
```text
AssertionError: expected 'original' to be 'replacement' // Object.is equality
Test Files 1 failed (1)
Tests 4 failed | 12 passed (16)
```
### After
`pnpm exec vitest run --project unit packages/lexical-clipboard/src/__tests__/unit`
```text
Test Files 5 passed (5)
Tests 40 passed (40)
```
`pnpm run tsc && pnpm run tsc-test` exited successfully:
```text
$ tsc
$ tsc -p ./tsconfig.test.json
```
`pnpm run flow`:
```text
Running Flow...
Found 0 errors
```
ESLint and `git diff --check` passed. Prettier reported:
```text
All matched files use Prettier code style!
```
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
potatowagon
left a comment
There was a problem hiding this comment.
The implementation is correct and the approach is the right one. I traced the threading: every default handler already uses its selection parameter rather than re-reading $getSelection() — $defaultLexicalEditorImporter and $defaultHtmlImporter pass it to $insertGeneratedNodes, and $defaultPlainTextImporter promotes it via $setSelection — so a replaced selection genuinely changes where content lands with no further changes needed. The default-parameter closure gives $next() ≡ $next(data, selection) for free, replacements stay scoped to one MIME-type stack, and widening the $next type is backwards compatible (and the type is @experimental anyway).
The doc correction bundled into the same hunk is also right: returning false abandons the whole stack for that MIME type, it does not fall through to the next-lower handler.
A few things below, one of which is a genuine semantic gap.
Major
1. The webkit rich-text e2e job is red on this head.
e2e-tests / mac-rich (24.x, webkit, rich-text) has failed on b889a3a through run attempt 2, and a further attempt is in flight as I write this. The last five commits on main show no webkit failure, so it does not look like the current baseline flake — and the one code path this PR changes is paste. Worth confirming it goes green, or a note explaining why it is unrelated, before this lands.
Minor
2. $next('') has undefined semantics, and probably does the wrong thing.
$runImport skips a MIME type outright when the payload is empty:
const data = dataTransfer.getData(mime);
if (!data) {
continue;
}so until now "empty" meant "nothing to import" and no handler was ever written for it. Middleware can now hand '' down the stack, and $defaultPlainTextImporter will tokenize it into zero tokens, insert nothing, and still return true. With a non-collapsed selection that means the selected text is not deleted and the paste is claimed, so the next MIME type never gets a chance. A sanitizer that strips HTML down to nothing — precisely the transformPastedHTML use case this PR is for — would silently do nothing rather than clearing the selection.
The PR explicitly calls an empty replacement valid, so this deserves a decision and a line of documentation: either '' means "handled, insert nothing" (today's behaviour), or an empty replacement should bail out to the next MIME type.
3. No test for empty data combined with a replaced selection.
The matrix covers {data: '', replaceSelection: false} but not true, which is exactly the case in (2).
4. No test for the "does not leak to another MIME type" claim.
The new paragraph in dom-import.md promises that replacements do not affect the arguments used when trying another MIME type. That is true today — $runImport re-reads getData(mime) and passes its own selection each iteration — but it is the kind of guarantee worth pinning down: a handler that replaces and then returns false, with a second MIME type asserting it saw the originals.
5. A replaced selection is not validated.
$defaultPlainTextImporter will $setSelection whatever it is handed, including a selection that does not belong to the active editor state. One sentence in the JSDoc saying the replacement must belong to the active editor state would save someone a confusing debugging session.
6. The JSDoc's "mirrors the export side" line is now stale.
It still says the type "Mirrors the shape of {@link ExportMimeTypeFunction} on the export side", but the export side is next: () => null | string (unprefixed next, no arguments) in clipboard.ts. The two have diverged — either soften the sentence or note that the export-side counterpart is intended to follow.
Nits
7. nextData?: string | undefined — the | undefined is redundant on an optional parameter in TypeScript; nextData?: string is equivalent. (The Flow file's string | void is correct as written.)
8. const expectedData = replacementData; in the test is a pointless alias.
9. The 'unchanged arguments' matrix row is mislabelled: that handler still calls $next('original') explicitly, so it tests "a replacement that happens to equal the original", not bare $next(). Bare $next() is covered by the second handler in the stack and by the pre-existing deferral test.
10. The Flow file now exports ImportMimeTypeFunction, but declares no ClipboardImportExtension or ImportMimeTypeConfig, so a Flow consumer gets a type they cannot actually wire up. Not introduced by this PR, just newly visible.
Edge cases I checked and found fine
- Calling
$nextmore than once from a single handler — pre-existing behaviour, still coherent. - A handler storing
$nextand calling it later — the closure captures its owncurrentData/currentSelection, so it stays correct. - The iOS Safari
text/html === text/plainskip — runs before the stack, unaffected. - Mutating the forwarded selection object in place — same reference as before, no new hazard.
- Type variance for existing implementors of
ImportMimeTypeFunction— widening$next's signature breaks nobody.
|
A data point from the wordpaste side, since that is the consumer this is for. In practice the sanitizer rarely returns For reference, ProseMirror, which the PR cites as the model, treats this as "replace the selection with nothing": |
… arguments
## Description
Clarify that empty replacement data is forwarded as-is without automatically falling back to another MIME type, and that selection arguments must reference the active editor state. Remove the stale comparison with the export callback and redundant undefined unions on optional TypeScript parameters.
Remove the redundant unchanged-data matrix row and expectedData alias from the existing middleware tests. Runtime behavior is unchanged.
## Test plan
### After
`node_modules/.bin/vitest run --project unit packages/lexical-clipboard/src/__tests__/unit/ClipboardImportExtension.test.ts`
```text
Test Files 1 passed (1)
Tests 15 passed (15)
```
ESLint, Prettier, and `git diff --check` passed. Browser tests were not rerun for this documentation and test cleanup.
…ML transform ordering
## Description
Explain how HTML transform configuration takes precedence over the legacy default importer and ClipboardDOMImportExtension. Show a dependency that guarantees ordering, the required order for independent root siblings, and an optional peer dependency for transforms that support either importer.
Replace the manual HTML parser example with examples that delegate transformed HTML through $next. Clarify that MIME priority and JavaScript declaration order do not control the handler stack.
## Test plan
### After
Traced LexicalBuilder's dependency sort and configuration merge order. Ran a temporary HTML paste probe for the legacy importer, both sibling orders, both explicit-dependency root orders, and the optional peer dependency with and without DOM import. Removed the temporary probe after verification; no test cases added to the suite.
`node_modules/.bin/vitest run --project unit packages/lexical-clipboard/src/__tests__/unit/ClipboardImportOrder.probe.test.ts`
```text
Test Files 1 passed (1)
Tests 1 passed (1)
```
`node_modules/.bin/prettier --check packages/lexical-clipboard/src/ClipboardImportExtension.ts`
```text
Checking formatting...
All matched files use Prettier code style!
```
`git diff --check` passed. Browser tests were not rerun for this documentation-only change.
… import ordering ## Description Focus the HTML transform documentation on two examples: a direct dependency on ClipboardDOMImportExtension, and an optional peer dependency for a transform that supports either importer. Remove the sibling-order example and its caveats. Name ClipboardDOMImportExtension in the import-context explanation now that the preceding example uses that extension. ## Test plan ### After Reviewed the revised Markdown and ran `git diff --check` (exit 0). The two documented dependency patterns were verified by the HTML paste probe in the preceding documentation change. Runtime behavior is unchanged.
…onfiguration ## Description Inline the clipboard configuration in each transform extension example so the extension that contributes it is visible. State that the peer dependency orders this configuration after the DOM importer's configuration, making the transform run first. ## Test plan ### After Reviewed both examples and ran `git diff --check` (exit 0). The configuration and dependency relationships are unchanged from the previously verified examples.
…normalization ## Description Add a tip distinguishing HTML transforms for libraries that accept and return strings from DOM-based normalization. Recommend a DOM import preprocessor to avoid an extra serialization and parse, with a link to the preprocessor documentation. ## Test plan ### After Reviewed the tip, confirmed its link targets the existing Preprocessors section, and ran `git diff --check` (exit 0). Documentation-only change.
## Description The changes merged since v0.52.0 predate changesets, so without entries the v0.53.0 section would leave them out, including the breaking removal of the deprecated import extensions (#9316). This adds a changeset for every user-facing pull request in v0.52.0..main, written from each pull request, with a `PR: #N` line (they land in this pull request rather than the original ones) and the original author's handle: - breaking: #9316, with the full replacement table as `Migration:` - feature: #9312 - fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319, #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302, #9261, #9262, #9263, #9258 - perf: #9264 Skipped as not user-facing: dependency bumps (all devDependencies), website and docs updates, test and CI changes, the private devtools extension and eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to `any` change). It also adds a `[chore]` changeset for this pull request itself, which adds CHANGELOG.md to the `lexical` package's `files`. ## Test plan ### Before ``` $ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn # at the previous commit warning: This pull request changes published code without a changeset for: lexical: packages/lexical/package.json (files) ... Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only. ``` ### After ``` $ node scripts/changesets/check.mjs --base origin/main Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset. ``` The `latest` release step in a throwaway clone of this branch, with the real tags: ``` $ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30 Added v0.53.0 to CHANGELOG.md from 27 changeset(s). $ ls .changeset changelog.cjs config.json README.md $ sed -n 1,9p CHANGELOG.md ## v0.53.0 (2026-10-30) ### Breaking changes - **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316)) The deprecated import and alias extensions are removed. The `*ImportRules` arrays, including `HorizontalRuleImportRules`, stay. $ grep -n '^### ' CHANGELOG.md | head -7 3:### Breaking changes 28:### Features 36:### Fixes 98:### Performance 102:### Other 106:### Contributors 110:### All changes $ sed -n '/^### Contributors/,+2p' CHANGELOG.md ### Contributors @Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira $ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2 - [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou - [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry ``` (`### All changes` has 50 lines: the 48 commits after v0.52.0, without the `v0.52.0 (#9252)` bump commit, plus this branch's two commits.) Running again before that release PR is merged: ``` $ git tag v0.53.0 # tagged, but CHANGELOG.md on main has no v0.53.0 section $ npm_package_version=0.54.0 node scripts/changesets/release.mjs CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases. (exit 1) $ npm_package_version=0.53.1 node scripts/changesets/release.mjs Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release: - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier Run the release with the "minor" increment instead. (exit 1) ``` A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built, so the export check that follows fails as expected): ``` $ node scripts/npm/prepare-release.mjs [lexical] CHANGELOG.md lists pending changes as Unreleased [lexical] package.json references files that are not present in packages/lexical: ./dist/Lexical.dev.js $ sed -n 1,5p packages/lexical/CHANGELOG.md ## Unreleased Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut. ### Breaking changes $ git status --short CHANGELOG.md (clean: only the gitignored package copy changed) ```
## Description The changes merged since v0.52.0 predate changesets, so without entries the v0.53.0 section would leave them out, including the breaking removal of the deprecated import extensions (#9316). This adds a changeset for every user-facing pull request in v0.52.0..main, written from each pull request, with a `PR: #N` line (they land in this pull request rather than the original ones) and the original author's handle: - breaking: #9316, with the full replacement table as `Migration:` - feature: #9312 - fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319, #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302, #9261, #9262, #9263, #9258 - perf: #9264 Skipped as not user-facing: dependency bumps (all devDependencies), website and docs updates, test and CI changes, the private devtools extension and eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to `any` change). Four fixes change observable output or behavior, so their changesets have a `Verify:` paragraph and are listed under Behavior changes: #9303 (new tabs get no `window.opener`), #9272 (imported code content is normalized), #9261 (`$patchStyleText` styles the selection it is given), #9319 (editor keys and namespaces are a counter without a DOM). It also adds a `[chore]` changeset for this pull request itself, which adds CHANGELOG.md to the `lexical` package's `files`. ## Test plan ### Before ``` $ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn # at the previous commit warning: This pull request changes published code without a changeset for: lexical: packages/lexical/package.json (files) ... Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only. ``` ### After ``` $ node scripts/changesets/check.mjs --base origin/main Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset. ``` The `latest` release step in a throwaway clone of this branch, with the real tags: ``` $ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30 Added v0.53.0 to CHANGELOG.md from 27 changeset(s). $ ls .changeset changelog.cjs config.json README.md $ sed -n 1,9p CHANGELOG.md ## v0.53.0 (2026-10-30) ### Breaking changes - **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316)) The deprecated import and alias extensions are removed. The `*ImportRules` arrays, including `HorizontalRuleImportRules`, stay. $ grep -n '^### ' CHANGELOG.md | head -8 3:### Breaking changes 28:### Behavior changes 54:### Features 62:### Fixes 108:### Performance 112:### Other 116:### Contributors 120:### All changes $ sed -n '/^### Behavior changes/,+7p' CHANGELOG.md ### Behavior changes - **@lexical/link**: Open new-tab links from `ClickableLinkPlugin` / `registerClickableLink` without `window.opener` ([#9303](#9303)) This prevents the opened page from navigating the editor's tab (reverse tabnabbing). Same-tab opens are unchanged. Verify: pages opened from editor links that relied on `window.opener`. $ node scripts/changesets/range.mjs --from 0.52.0 --breaking --json # (kind, [(pr, behavior)]) [('breaking', [(9316, False)]), ('behavior', [(9303, True), (9272, True), (9261, True), (9319, True)])] $ sed -n '/^### Contributors/,+2p' CHANGELOG.md ### Contributors @Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira $ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2 - [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou - [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry ``` (`### All changes` has 50 lines: the 48 commits after v0.52.0, without the `v0.52.0 (#9252)` bump commit, plus this branch's two commits.) Running again before that release PR is merged: ``` $ git tag v0.53.0 # tagged, but CHANGELOG.md on main has no v0.53.0 section $ npm_package_version=0.54.0 node scripts/changesets/release.mjs CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases. (exit 1) $ npm_package_version=0.53.1 node scripts/changesets/release.mjs Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release: - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier Run the release with the "minor" increment instead. (exit 1) ``` A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built, so the export check that follows fails as expected): ``` $ node scripts/npm/prepare-release.mjs [lexical] CHANGELOG.md lists pending changes as Unreleased [lexical] package.json references files that are not present in packages/lexical: ./dist/Lexical.dev.js $ sed -n 1,5p packages/lexical/CHANGELOG.md ## Unreleased Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut. ### Breaking changes $ git status --short CHANGELOG.md (clean: only the gitignored package copy changed) ```
## Description The changes merged since v0.52.0 predate changesets, so without entries the v0.53.0 section would leave them out, including the breaking removal of the deprecated import extensions (#9316). This adds a changeset for every user-facing pull request in v0.52.0..main, written from each pull request, with a `PR: #N` line (they land in this pull request rather than the original ones) and the original author's handle: - breaking: #9316, with the full replacement table as `Migration:` - feature: #9312 - fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319, #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302, #9261, #9262, #9263, #9258 - perf: #9264 Skipped as not user-facing: dependency bumps (all devDependencies), website and docs updates, test and CI changes, the private devtools extension and eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to `any` change). Four fixes change observable output or behavior, so their changesets have a `Verify:` paragraph and are listed under Behavior changes: #9303 (new tabs get no `window.opener`), #9272 (imported code content is normalized), #9261 (`$patchStyleText` styles the selection it is given), #9319 (editor keys and namespaces are a counter without a DOM). It also adds a `[chore]` changeset for this pull request itself, which adds CHANGELOG.md to the `lexical` package's `files`. ## Test plan ### Before ``` $ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn # at the previous commit warning: This pull request changes published code without a changeset for: lexical: packages/lexical/package.json (files) ... Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only. ``` ### After ``` $ node scripts/changesets/check.mjs --base origin/main Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset. ``` The `latest` release step in a throwaway clone of this branch, with the real tags: ``` $ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30 Added v0.53.0 to CHANGELOG.md from 27 changeset(s). $ ls .changeset changelog.cjs config.json README.md $ sed -n 1,9p CHANGELOG.md ## v0.53.0 (2026-10-30) ### Breaking changes - **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316)) The deprecated import and alias extensions are removed. The `*ImportRules` arrays, including `HorizontalRuleImportRules`, stay. $ grep -n '^### ' CHANGELOG.md | head -8 3:### Breaking changes 28:### Behavior changes 54:### Features 62:### Fixes 108:### Performance 112:### Other 116:### Contributors 120:### All changes $ sed -n '/^### Behavior changes/,+7p' CHANGELOG.md ### Behavior changes - **@lexical/link**: Open new-tab links from `ClickableLinkPlugin` / `registerClickableLink` without `window.opener` ([#9303](#9303)) This prevents the opened page from navigating the editor's tab (reverse tabnabbing). Same-tab opens are unchanged. Verify: pages opened from editor links that relied on `window.opener`. $ node scripts/changesets/range.mjs --from 0.52.0 --breaking --json # (kind, [(pr, behavior)]) [('breaking', [(9316, False)]), ('behavior', [(9303, True), (9272, True), (9261, True), (9319, True)])] $ sed -n '/^### Contributors/,+2p' CHANGELOG.md ### Contributors @Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira $ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2 - [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou - [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry ``` (`### All changes` has 50 lines: the 48 commits after v0.52.0, without the `v0.52.0 (#9252)` bump commit, plus this branch's two commits.) Running again before that release PR is merged: ``` $ git tag v0.53.0 # tagged, but CHANGELOG.md on main has no v0.53.0 section $ npm_package_version=0.54.0 node scripts/changesets/release.mjs CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases. (exit 1) $ npm_package_version=0.53.1 node scripts/changesets/release.mjs Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release: - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier Run the release with the "minor" increment instead. (exit 1) ``` A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built, so the export check that follows fails as expected): ``` $ node scripts/npm/prepare-release.mjs [lexical] CHANGELOG.md lists pending changes as Unreleased [lexical] package.json references files that are not present in packages/lexical: ./dist/Lexical.dev.js $ sed -n 1,5p packages/lexical/CHANGELOG.md ## Unreleased Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut. ### Breaking changes $ git status --short CHANGELOG.md (clean: only the gitignored package copy changed) ```
Description
Adds the capability for clipboard import middleware to transform pasted HTML, equivalent in purpose to prosemirror/TipTap's transformPastedHTML. This makes it easier to use off-the-shelf HTML normalization code such as wordpaste, re: #9306
Clipboard import middleware currently delegates through a zero-argument
$next()callback, so every handler receives the original data and selection. Allow$next(data?, selection?)to replace either argument for the remaining handlers in that MIME-type stack.Test plan
New unit tests to confirm functionality