From cda5fe7a5f24f48035cb045ad2ad41b552bf8b5e Mon Sep 17 00:00:00 2001 From: rameel Date: Mon, 22 Dec 2025 01:41:07 +0500 Subject: [PATCH] x-bound: Support contenteditable="plaintext-only" --- src/plugins/bound/index.js | 2 +- tests/playwright/x-bound.spec.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/plugins/bound/index.js b/src/plugins/bound/index.js index 12246db..a22ef93 100644 --- a/src/plugins/bound/index.js +++ b/src/plugins/bound/index.js @@ -219,7 +219,7 @@ function plugin({ directive, entangle, evaluateLater, mapAttributes, mutateDom, } function process_contenteditable() { - if (el.contentEditable === "true") { + if (el.isContentEditable) { is_nullish(get_value()) && update_variable(); effect(update_property); diff --git a/tests/playwright/x-bound.spec.js b/tests/playwright/x-bound.spec.js index d70ef97..9b7aaf1 100644 --- a/tests/playwright/x-bound.spec.js +++ b/tests/playwright/x-bound.spec.js @@ -425,6 +425,22 @@ test.describe("x-bound: contenteditable", () => { await expect(page.locator("span")).toContainText("Hello World!"); }); + test("supports contenteditable='plaintext-only'", async ({ page }) => { + await set_html(page, ` +
+

+                
+                {{ innerHTML }}
+            
`); + + await expect(page.locator("span")).toContainText("

Sample

"); + await page.locator("button").click(); + await expect(page.locator("span")).toContainText("Hello!"); + await page.locator("pre").clear(); + await page.locator("pre").fill("Hello World!"); + await expect(page.locator("span")).toContainText("Hello World!"); + }); + test("innerHTML (initliaze from element when property is null)", async ({ page }) => { await set_html(page, `