From f56fe339318d8faee57d0392b44e3079c819ca56 Mon Sep 17 00:00:00 2001 From: Dave Lunny <4298089+himynameisdave@users.noreply.github.com> Date: Thu, 16 Mar 2023 02:58:49 -0700 Subject: [PATCH] feat: `bind:innerText` for `contenteditable` (#4291) closes #3311 --------- Co-authored-by: Simon Holthausen --- elements/index.d.ts | 8 ++- site/content/docs/03-template-syntax.md | 7 +- .../08-contenteditable-bindings/text.md | 9 ++- src/compiler/compile/compiler_errors.ts | 2 +- src/compiler/compile/nodes/Element.ts | 11 +-- .../render_dom/wrappers/Element/Binding.ts | 5 ++ .../render_dom/wrappers/Element/index.ts | 18 +++-- .../compile/render_ssr/handlers/Element.ts | 12 ++-- src/compiler/compile/utils/__test__.ts | 67 +++++++++++++++++++ src/compiler/compile/utils/contenteditable.ts | 57 ++++++++++++++++ .../_config.js | 25 +++++++ .../main.svelte | 6 ++ .../errors.json | 2 +- .../contenteditable-missing/errors.json | 2 +- 14 files changed, 198 insertions(+), 33 deletions(-) create mode 100644 src/compiler/compile/utils/contenteditable.ts create mode 100644 test/runtime/samples/binding-contenteditable-innertext/_config.js create mode 100644 test/runtime/samples/binding-contenteditable-innertext/main.svelte diff --git a/elements/index.d.ts b/elements/index.d.ts index 72a077a7d5..4ad2f2880f 100644 --- a/elements/index.d.ts +++ b/elements/index.d.ts @@ -534,13 +534,17 @@ export interface HTMLAttributes extends AriaAttributes, D is?: string | undefined | null; /** - * Elements with the contenteditable attribute support innerHTML and textContent bindings. + * Elements with the contenteditable attribute support `innerHTML`, `textContent` and `innerText` bindings. */ 'bind:innerHTML'?: string | undefined | null; /** - * Elements with the contenteditable attribute support innerHTML and textContent bindings. + * Elements with the contenteditable attribute support `innerHTML`, `textContent` and `innerText` bindings. */ 'bind:textContent'?: string | undefined | null; + /** + * Elements with the contenteditable attribute support `innerHTML`, `textContent` and `innerText` bindings. + */ + 'bind:innerText'?: string | undefined | null; // SvelteKit 'data-sveltekit-keepfocus'?: true | '' | 'off' | undefined | null; diff --git a/site/content/docs/03-template-syntax.md b/site/content/docs/03-template-syntax.md index 95d76db5b7..170c303b85 100644 --- a/site/content/docs/03-template-syntax.md +++ b/site/content/docs/03-template-syntax.md @@ -691,7 +691,12 @@ When the value of an `