Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component ignores "i" and "s" props in debug mode #1957

Closed
michaelkryukov opened this issue Sep 30, 2019 · 1 comment · Fixed by #1958
Closed

Component ignores "i" and "s" props in debug mode #1957

michaelkryukov opened this issue Sep 30, 2019 · 1 comment · Fixed by #1958

Comments

@michaelkryukov
Copy link

Do you want to request a feature or report a bug?
bug

What is the current behaviour?
Preact pops i and s from props, confusing them with __source and __self.

If the current behaviour is a bug, please provide the steps to reproduce.
Example application: https://codesandbox.io/s/focused-yalow-fiqpy.

I used the debugger to follow execution and got to part:

  preact__WEBPACK_IMPORTED_MODULE_0__["options"].vnode = function (e) {
    var n, t;
    e.props && e.props.i && (n = e.props.i, delete e.props.i), e.props && e.props.s && (t = e.props.s, delete e.props.s), e.s = t, e.i = n, Object.defineProperties(e, l), o && o(e);
  }, preact__WEBPACK_IMPORTED_MODULE_0__["options"].diffed = function (e) {
// ...

Here line e.props && e.props.i && (n = e.props.i, delete e.props.i), e.props && e.props.s && (t = e.props.s, delete e.props.s), e.s = t, e.i = n, Object.defineProperties(e, l), o && o(e); "pops" i and s from props and rewrites it to the component.

I checked sources from npm:

wget $(npm view preact@next dist.tarball)
tar -xvzf preact-10.0.0-rc.3.tgz
cat package/debug/dist/debug.js | grep "e.props&&e.props.i&&(n=e.props.i,delete e.props.i)"; echo $? 

You will see 0, as grep will find troubling part.

What is the expected behaviour?
Props __self and __source should not be mangled to i and s.

Please mention other relevant information.
I noticed this problem, while trying to use https://github.com/STRML/react-grid-layout, which uses a prop with the name "i". I was getting strange errors about missing required props.

Seems like this issue was present in all 10.0.0 versions, but for different prop names.

$ preact info

Environment Info:

  System:
    OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
    CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
  Binaries:
    Node: 12.10.0 - /usr/bin/node
    Yarn: 1.19.0 - /usr/bin/yarn
    npm: 6.11.3 - /usr/bin/npm
  Browsers:
    Chrome: 77.0.3865.90
    Firefox: 66.0.3
  npmGlobalPackages:
    preact-cli: 3.0.0-rc.5
@JoviDeCroock
Copy link
Member

Hey, thank you so much for this issue report. The research has made it easy for me to file the appropriate fix and is now in pull request. Thank you for the effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants