Closed sn3p closed 4 years ago
Hi @sn3p,
Yikes! Thanks for reporting this. I just released this feature and must have missed the error in testing. I'm going to work on a fix this morning.
I just pushed up a fix as v5.2.5
. Can you give it a try and let me know if that fixes the issue? If not, please let me know what browser version you're seeing the issue in.
@ten1seven thanks for the fast response, but sorry that doesn't fix my issue 😢
The problem is that document.body
is undefined, so calling getAttribute
on body results in the same error:
Uncaught TypeError: Cannot read property 'getAttribute' of null
The weird thing is that document.body
is null
here 🤔
If not, please let me know what browser version you're seeing the issue in.
I'm using Chrome 77.0.3865.90 on macOS (latest at the time of writing).
Looks like document.body
isn't available yet at the time of execution. In other words the DOM is not ready (similar issue here).
My app.js is included in the head
of the document. Here is a part of the source to illustrate the problem:
// import "what-input";
console.log(document.body); // null
document.addEventListener("DOMContentLoaded", () => {
console.log(document.body); // <body>...</body>
});
Yes, of course! I should know better. Thanks for investigating that. I’ll have that update for you shortly.
Version 5.2.6 is now up for you to try out. I tested more thoroughly by moving the script tag into the <head>
. Should work now.
Yes!! Works perfectly many thanks for the quick fix ⚡️
Hi In my case , it was fixed only by rebuilding and serve. Thank You
I think this is jquery version error please update jquery version
@xcelance jQuery isn't used in what-input
Got an error bumping what-input from 5.2.3 to 5.2.4:
At line:
https://github.com/ten1seven/what-input/blob/ec9a7d23ed6aa6b3c66d42f603069e4dd8131749/dist/what-input.js#L118
(breaks on
document.body.dataset.whatpersist
to be precise)Not sure why
body
is null here, but maybe be because we're using Turbolinks in our app?