Jelajahi Sumber

Correction test si form ou non

Sangfroid 2 bulan lalu
induk
melakukan
54fcb0b9ba
1 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 4 4
      assets/controllers/resize_controller.js

+ 4 - 4
assets/controllers/resize_controller.js

@@ -6,10 +6,10 @@ export default class extends Controller {
         const form = document.querySelector('form')
         if (sessionStorage.getItem('size')) {
             main.classList.toggle('size-max', true)
-            form.classList.toggle('size-max-form', true)
+            if (form) form.classList.toggle('size-max-form', true)
         } else {
             main.classList.toggle('size-max', false)
-            form.classList.toggle('size-max-form', false)
+            if (form) form.classList.toggle('size-max-form', false)
         }
     }
     
@@ -17,10 +17,10 @@ export default class extends Controller {
         const main = document.querySelector('main')
         const form = document.querySelector('form')
         if (main.classList.toggle('size-max')) {
-            form.classList.toggle('size-max-form', true)
+            if (form) form.classList.toggle('size-max-form', true)
             sessionStorage.setItem('size', 'size-max')
         } else {
-            form.classList.toggle('size-max-form', false)
+            if (form) form.classList.toggle('size-max-form', false)
             sessionStorage.removeItem('size')
         }
     }