diff --git a/packages/@lwc/jest-preset/src/ssr/html-serializer.js b/packages/@lwc/jest-preset/src/ssr/html-serializer.js
index 4710016..fbfc79d 100644
--- a/packages/@lwc/jest-preset/src/ssr/html-serializer.js
+++ b/packages/@lwc/jest-preset/src/ssr/html-serializer.js
@@ -104,8 +104,10 @@ function formatHTML(src) {
res
.trim()
.replace(getKnownScopeTokensRegex(), '__lwc_scope_token__')
- // These special attributes are reserved by the framework and are meaningless to component authors
- .replace(/ data-lwc-host-mutated/g, '')
+ // These special attributes are reserved by the framework and are meaningless to component authors.
+ // `data-lwc-host-mutated` may or may not have an attribute value depending on the version of LWC.
+ // See: https://github.com/salesforce/lwc/pull/4385
+ .replace(/ data-lwc-host-mutated(="[^"]*")?/g, '')
.replace(/ data-rendered-by-lwc/g, '')
);
}
diff --git a/test/src/modules/serializer/frameworkAttrsWithValue/__tests__/__snapshots__/frameworkAttrsWithValue.spec.js.snap b/test/src/modules/serializer/frameworkAttrsWithValue/__tests__/__snapshots__/frameworkAttrsWithValue.spec.js.snap
new file mode 100644
index 0000000..f19cdf3
--- /dev/null
+++ b/test/src/modules/serializer/frameworkAttrsWithValue/__tests__/__snapshots__/frameworkAttrsWithValue.spec.js.snap
@@ -0,0 +1,9 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`serializes a component containing framework-supplied attributes 1`] = `
+
+
+ Hello world
+
+
+`;
diff --git a/test/src/modules/serializer/frameworkAttrsWithValue/__tests__/frameworkAttrsWithValue.spec.js b/test/src/modules/serializer/frameworkAttrsWithValue/__tests__/frameworkAttrsWithValue.spec.js
new file mode 100644
index 0000000..897eb94
--- /dev/null
+++ b/test/src/modules/serializer/frameworkAttrsWithValue/__tests__/frameworkAttrsWithValue.spec.js
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2024, Salesforce, Inc.
+ * All rights reserved.
+ * SPDX-License-Identifier: MIT
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
+ */
+import { createElement } from 'lwc';
+import FrameworkAttrsWithValue from '../frameworkAttrsWithValue';
+
+it('serializes a component containing framework-supplied attributes', () => {
+ const elm = createElement('serializer-component', { is: FrameworkAttrsWithValue });
+ document.body.appendChild(elm);
+
+ expect(elm).toMatchSnapshot();
+});
diff --git a/test/src/modules/serializer/frameworkAttrsWithValue/frameworkAttrsWithValue.css b/test/src/modules/serializer/frameworkAttrsWithValue/frameworkAttrsWithValue.css
new file mode 100644
index 0000000..03d0aca
--- /dev/null
+++ b/test/src/modules/serializer/frameworkAttrsWithValue/frameworkAttrsWithValue.css
@@ -0,0 +1,3 @@
+h1 {
+ color: blue;
+}
diff --git a/test/src/modules/serializer/frameworkAttrsWithValue/frameworkAttrsWithValue.html b/test/src/modules/serializer/frameworkAttrsWithValue/frameworkAttrsWithValue.html
new file mode 100644
index 0000000..77dc69f
--- /dev/null
+++ b/test/src/modules/serializer/frameworkAttrsWithValue/frameworkAttrsWithValue.html
@@ -0,0 +1,3 @@
+
+ Hello world
+
diff --git a/test/src/modules/serializer/frameworkAttrsWithValue/frameworkAttrsWithValue.js b/test/src/modules/serializer/frameworkAttrsWithValue/frameworkAttrsWithValue.js
new file mode 100644
index 0000000..e3b8cc7
--- /dev/null
+++ b/test/src/modules/serializer/frameworkAttrsWithValue/frameworkAttrsWithValue.js
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2018, salesforce.com, inc.
+ * All rights reserved.
+ * SPDX-License-Identifier: MIT
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
+ */
+
+import { LightningElement } from 'lwc';
+
+export default class FrameworkAttrsWithValue extends LightningElement {
+ static renderMode = 'light';
+
+ connectedCallback() {
+ // Typically this is only added by the framework itself, but here we are explicitly adding it
+ // to make the test simpler
+ this.setAttribute('data-lwc-host-mutated', 'class data-foo');
+ }
+}
diff --git a/test/src/modules/ssr/frameworkAttrsWithValue/__tests__/__snapshots__/frameworkAttrsWithValue.ssr-test.js.snap b/test/src/modules/ssr/frameworkAttrsWithValue/__tests__/__snapshots__/frameworkAttrsWithValue.ssr-test.js.snap
new file mode 100644
index 0000000..396d779
--- /dev/null
+++ b/test/src/modules/ssr/frameworkAttrsWithValue/__tests__/__snapshots__/frameworkAttrsWithValue.ssr-test.js.snap
@@ -0,0 +1,12 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`serializes component with framework-supplied attributes with value 1`] = `
+
+
+
+ Hello world
+
+
+`;
diff --git a/test/src/modules/ssr/frameworkAttrsWithValue/__tests__/frameworkAttrsWithValue.ssr-test.js b/test/src/modules/ssr/frameworkAttrsWithValue/__tests__/frameworkAttrsWithValue.ssr-test.js
new file mode 100644
index 0000000..79b0cdc
--- /dev/null
+++ b/test/src/modules/ssr/frameworkAttrsWithValue/__tests__/frameworkAttrsWithValue.ssr-test.js
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2018, salesforce.com, inc.
+ * All rights reserved.
+ * SPDX-License-Identifier: MIT
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
+ */
+import { renderComponent } from 'lwc';
+import FrameworkAttrsWithValue from '../frameworkAttrsWithValue';
+
+it('serializes component with framework-supplied attributes with value', () => {
+ const renderedComponent = renderComponent('x-basic', FrameworkAttrsWithValue, {});
+
+ expect(renderedComponent).toMatchSnapshot();
+});
diff --git a/test/src/modules/ssr/frameworkAttrsWithValue/frameworkAttrsWithValue.css b/test/src/modules/ssr/frameworkAttrsWithValue/frameworkAttrsWithValue.css
new file mode 100644
index 0000000..03d0aca
--- /dev/null
+++ b/test/src/modules/ssr/frameworkAttrsWithValue/frameworkAttrsWithValue.css
@@ -0,0 +1,3 @@
+h1 {
+ color: blue;
+}
diff --git a/test/src/modules/ssr/frameworkAttrsWithValue/frameworkAttrsWithValue.html b/test/src/modules/ssr/frameworkAttrsWithValue/frameworkAttrsWithValue.html
new file mode 100644
index 0000000..77dc69f
--- /dev/null
+++ b/test/src/modules/ssr/frameworkAttrsWithValue/frameworkAttrsWithValue.html
@@ -0,0 +1,3 @@
+
+ Hello world
+
diff --git a/test/src/modules/ssr/frameworkAttrsWithValue/frameworkAttrsWithValue.js b/test/src/modules/ssr/frameworkAttrsWithValue/frameworkAttrsWithValue.js
new file mode 100644
index 0000000..e3b8cc7
--- /dev/null
+++ b/test/src/modules/ssr/frameworkAttrsWithValue/frameworkAttrsWithValue.js
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2018, salesforce.com, inc.
+ * All rights reserved.
+ * SPDX-License-Identifier: MIT
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
+ */
+
+import { LightningElement } from 'lwc';
+
+export default class FrameworkAttrsWithValue extends LightningElement {
+ static renderMode = 'light';
+
+ connectedCallback() {
+ // Typically this is only added by the framework itself, but here we are explicitly adding it
+ // to make the test simpler
+ this.setAttribute('data-lwc-host-mutated', 'class data-foo');
+ }
+}