Merge pull request #164 from simkimsia/fix-163

🐛Prevent potential null elements
This commit is contained in:
Emil Stenström 2022-07-26 20:13:57 +02:00 committed by GitHub
commit cbebba23e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -220,7 +220,9 @@ Then you need a javascript file that specifies how you interact with this compon
```js ```js
/* In a file called [project root]/components/calendar/script.js */ /* In a file called [project root]/components/calendar/script.js */
(function(){ (function(){
document.querySelector(".calendar-component").onclick = function(){ alert("Clicked calendar!") } if (document.querySelector(".calendar-component")) {
document.querySelector(".calendar-component").onclick = function(){ alert("Clicked calendar!"); };
}
})() })()
``` ```

View file

@ -1,3 +1,5 @@
(function(){ (function(){
document.querySelector(".calendar-component").onclick = function(){alert("Clicked calendar!")} if (document.querySelector(".calendar-component")) {
document.querySelector(".calendar-component").onclick = function(){ alert("Clicked calendar!"); };
}
})() })()