Giter Club home page Giter Club logo

Comments (2)

stackblitz avatar stackblitz commented on July 17, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

from histoire.

DrJume avatar DrJume commented on July 17, 2024

We also experienced this bug. It only breaks the SourceCodePreview and it only happens, when no attributes or props are set on a the component of the story:

<Story>
  <MyComponent></MyComponent>
</Story>

Even setting an aria-label="test" makes it work again.

The issue lies here:

// @ts-ignore
const vmodelListener = vmodelListeners.find(key => vnode.dynamicProps?.includes(key) || key in vnode.props)

Because @ts-ignore is set and the project doesn't use TypeScript strict mode, the access to vnode.props is not marked as unsafe, as it can be null!

Just checking if vnode.props is truthy is enough to fix the bug:

- // @ts-ignore
- const vmodelListener = vmodelListeners.find(key => vnode.dynamicProps?.includes(key) || key in vnode.props)
+ const vmodelListener = vmodelListeners.find(key => vnode.dynamicProps?.includes(key) || (vnode.props && key in vnode.props))

Sadly the source code in the npm package is minified, but we still managed to patch it with pnpm:

diff --git a/dist/bundled/client/codegen.js b/dist/bundled/client/codegen.js
index 6b922b51e716d6e5df1d0efd8358cbbf36f656c5..13ccbaa62998ae2b7e7934b6303a20dd74223249 100644
--- a/dist/bundled/client/codegen.js
+++ b/dist/bundled/client/codegen.js
@@ -38,7 +38,7 @@ async function k(e, o = null) {
         t.startsWith("on") && (f = "@");
         const L = f === "@" ? `${t[2].toLowerCase()}${t.slice(3)}` : t, M = [`onUpdate:${t}`, `onUpdate:${N(t)}`].find((p) => {
           var $;
-          return (($ = e.dynamicProps) == null ? void 0 : $.includes(p)) || p in e.props;
+          return (($ = e.dynamicProps) == null ? void 0 : $.includes(p)) || (e.props && p in e.props);
         });
         if (f === ":" && M) {
           j.push(M);

from histoire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.