capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.4k stars 206 forks source link

Tests that set the value of a <meter> fail after upgrading to v15 #1601

Closed petegraves closed 1 week ago

petegraves commented 1 week ago

Describe the bug After upgrading to happy-dom 15, tests for a Vue component that set the value or max of a <meter> element have started failing.

To Reproduce

  1. Go to this StackBlitz example
  2. Upgrade happy-dom to ^15
  3. See error:

stderr | test/basic.test.ts > mount component [Vue warn]: Failed setting prop "max" on : value 10 is invalid. TypeError: Failed to set the 'max' property on 'HTMLMeterElement': The provided double value is non-finite. at set.max (file:///home/projects/vitest-dev-vitest-uu9zyg/node_modules/happy-dom/lib/nodes/html-meter-element/HTMLMeterElement.js:101:19) at patchDOMProp (/home/projects/vitest-dev-vitest-uu9zyg/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:597:13) at patchProp (/home/projects/vitest-dev-vitest-uu9zyg/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:708:5) at mountElement (/home/projects/vitest-dev-vitest-uu9zyg/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4790:11) at processElement (/home/projects/vitest-dev-vitest-uu9zyg/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4737:7) at patch (/home/projects/vitest-dev-vitest-uu9zyg/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4605:11) at ReactiveEffect.componentUpdateFn (/home/projects/vitest-dev-vitest-uu9zyg/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5232:11) at ReactiveEffect.run (/home/projects/vitest-dev-vitest-uu9zyg/node_modules/@vue/reactivity/dist/reactivity.cjs.js:226:19) at setupRenderEffect (/home/projects/vitest-dev-vitest-uu9zyg/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5360:5) at mountComponent (/home/projects/vitest-dev-vitest-uu9zyg/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5135:7)

Expected behavior Component mounts and HTML matches snapshot.

Additional context In HTMLMeterElement.ts there is typeof value !== 'number' added in https://github.com/capricorn86/happy-dom/issues/1332, but in patchDOMProp from @vue/runtime-dom/dist/runtime-dom.cjs.js the values are converted to Strings.

This error doesn't happen in happy-dom 14 or jsdom.

capricorn86 commented 1 week ago

Thank you for reporting @petegraves! :slightly_smiling_face:

I believe that it should be fixed now.

petegraves commented 1 week ago

Thanks @capricorn86!

Yes this is working now in 15.11.4