parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.43k stars 2.26k forks source link

get wrong value of document.documentElement.clientWidth #4489

Closed BrotaOne closed 4 years ago

BrotaOne commented 4 years ago

Hi everyone!

I use "npx parcel test.html" to start a server,but when I use chrome , the value of document.documentElement.clientWidth is always 768,but when I use edge with chromium ,I get the right value.

And if I open test.html directly with chrome, I also get the right value.

To find if the html file is wrong, I try with a html file with !+Tab in VScode, the result is the same .

I failed uploading my screenshot because of slow network.

Yesterday I used "npx parcel test.html",it works,so did i do something wrong ?

have a nice day!

mischnic commented 4 years ago

This should work. Can you provide a code sample?

BrotaOne commented 4 years ago

This should work. Can you provide a code sample?

After I found the problem, I tried it with a new html. There is only a little code. //test.html `<!DOCTYPE html>

Document ` //index.js (Nothing) //package.json `{ "name": "test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "parcel-bundler": "^1.12.4" } }`
mischnic commented 4 years ago

This isn't very helpful if your script doesn't even contain document.documentElement.clientWidth; with the code, I want to trigger the same problem you were having.

BrotaOne commented 4 years ago

This isn't very helpful if your script doesn't even contain document.documentElement.clientWidth; with the code, I want to trigger the same problem you were having.

So you can't trigger the same problem? But I didnt change document.documentElement.clientWidth in my script.

mischnic commented 4 years ago

So you can't trigger the same problem?

Where do you access document.documentElement.clientWidth? I ran your example, opened the devtools and printed the value using the console; and the value was correct.

BrotaOne commented 4 years ago

123 I get thewrong value in console of Chrome 81.0.4044.113, but in ms edge it is correct

mischnic commented 4 years ago

I have the same Chrome version.

What happens if you start a normal http server in your project directory (not parcel) and open the html file in the browser? If it's still wrong, then it's a bug in Chrome.

BrotaOne commented 4 years ago

I have the same Chrome version.

What happens if you start a normal http server in your project directory (not parcel) and open the html file in the browser? If it's still wrong, then it's a bug in Chrome.

Thank you! Maybe it is something wrong with my chrome,I use vue-cli-service to start a server,it is also wrong.But before it was right.

After all, thanks for your help.