Using window.onresize
and document.querySelector
is unsafe
#3
Labels
Milestone
window.onresize
and document.querySelector
is unsafe
#3
Question
It's not a bug, so I've chosen the "question" template. I looked at the source code, and I've found some worrying parts:
webcomponent-instagram-widget/webcomponent/js/main.js
Line 60 in 245e8c3
Your code won't work if there will be more elements on the same page. It will always update the first one. You can just reference your element by
this
- so instead querying document to access shadowRoot, you can usethis.shadowRoot
(after initializing it).webcomponent-instagram-widget/webcomponent/js/main.js
Line 110 in 245e8c3
This is unsafe and can break other code. You assume that the user won't use
window.onresize
syntax, but he can, and then your callback is gone. You should usewindow.addEventListener()
.webcomponent-instagram-widget/webcomponent/js/main.js
Line 113 in 245e8c3
Because of that, the
onresize
will only refer to the last instance of your component, so the above setting will apply from the last instance.The text was updated successfully, but these errors were encountered: