From fe257823ecca31cf5e582e9b8380a0ad0204075e Mon Sep 17 00:00:00 2001 From: Tiger Oakes Date: Tue, 12 Apr 2022 08:07:25 -0700 Subject: Use Babel and ES6 in docs JS files (#31607) * Pass docs js through Babel * Use ES6 in docs js * Only run babel on src files * Allow babel in Hugo * Update scripts.html * Inherit from the root .eslintrc.json * Use `Array.from` * Drop Babel from docs * Prefer template * replace IIFE with arrow functions Co-authored-by: XhmikosR Co-authored-by: GeoSot --- .../docs/5.1/examples/checkout/form-validation.js | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'site/content/docs/5.1/examples/checkout/form-validation.js') diff --git a/site/content/docs/5.1/examples/checkout/form-validation.js b/site/content/docs/5.1/examples/checkout/form-validation.js index f8fd583de..30ea0aa6b 100644 --- a/site/content/docs/5.1/examples/checkout/form-validation.js +++ b/site/content/docs/5.1/examples/checkout/form-validation.js @@ -1,20 +1,19 @@ // Example starter JavaScript for disabling form submissions if there are invalid fields -(function () { +(() => { 'use strict' // Fetch all the forms we want to apply custom Bootstrap validation styles to - var forms = document.querySelectorAll('.needs-validation') + const forms = document.querySelectorAll('.needs-validation') // Loop over them and prevent submission - Array.prototype.slice.call(forms) - .forEach(function (form) { - form.addEventListener('submit', function (event) { - if (!form.checkValidity()) { - event.preventDefault() - event.stopPropagation() - } + Array.from(forms).forEach(form => { + form.addEventListener('submit', event => { + if (!form.checkValidity()) { + event.preventDefault() + event.stopPropagation() + } - form.classList.add('was-validated') - }, false) - }) + form.classList.add('was-validated') + }, false) + }) })() -- cgit v1.2.3 From f7e8ca91e03165abb82d4c82555dc4ef96340cc9 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Fri, 6 May 2022 23:57:58 +0300 Subject: Prepare v5.2.0-beta1 --- .../docs/5.1/examples/checkout/form-validation.js | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 site/content/docs/5.1/examples/checkout/form-validation.js (limited to 'site/content/docs/5.1/examples/checkout/form-validation.js') diff --git a/site/content/docs/5.1/examples/checkout/form-validation.js b/site/content/docs/5.1/examples/checkout/form-validation.js deleted file mode 100644 index 30ea0aa6b..000000000 --- a/site/content/docs/5.1/examples/checkout/form-validation.js +++ /dev/null @@ -1,19 +0,0 @@ -// Example starter JavaScript for disabling form submissions if there are invalid fields -(() => { - 'use strict' - - // Fetch all the forms we want to apply custom Bootstrap validation styles to - const forms = document.querySelectorAll('.needs-validation') - - // Loop over them and prevent submission - Array.from(forms).forEach(form => { - form.addEventListener('submit', event => { - if (!form.checkValidity()) { - event.preventDefault() - event.stopPropagation() - } - - form.classList.add('was-validated') - }, false) - }) -})() -- cgit v1.2.3