From 28b1aa4f15e835b4df9c12fb53d4178f7d2dc7fb Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 29 Apr 2021 22:50:48 -0400 Subject: [PATCH] fix: HTML Validation issues --- files/en-us/glossary/iife/index.html | 30 +++++++++---------- .../capabilities/firefoxoptions/index.html | 2 +- files/en-us/web/webdriver/index.html | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/files/en-us/glossary/iife/index.html b/files/en-us/glossary/iife/index.html index 63a6391951f4d2a..f922c299169c337 100644 --- a/files/en-us/glossary/iife/index.html +++ b/files/en-us/glossary/iife/index.html @@ -26,16 +26,16 @@

Use cases

Avoid polluting the global namespace

-

Because our application could include many functions and global variables from different source files, it's +

Because our application could include many functions and global variables from different source files, it's important to limit the number of global variables. If we have some initiation code that we don't need to use -again, we could use the IIFE pattern. As we will not reuse the code again, using IIFE in this case is better than +again, we could use the IIFE pattern. As we will not reuse the code again, using IIFE in this case is better than using a function declaration or a function expression.

 (function () {
-  // some initiation code 
+  // some initiation code
   let firstVariable;
-  let secondVariable; 
+  let secondVariable;
 })();
 
 // firstVariable and secondVariable will be discarded after the function is executed.
@@ -49,7 +49,7 @@

The module pattern

const makeWithdraw = balance => (function(copyBalance) { let balance = copyBalance; // This variable is private let doBadThings = function() { - console.log("I will do bad things with your money"); + console.log("I will do bad things with your money"); }; doBadThings(); return { @@ -60,7 +60,7 @@

The module pattern

} else { return "Insufficient money"; } - }, + }, } })(balance); @@ -68,20 +68,20 @@

The module pattern

console.log(firstAccount.balance); // undefined console.log(firstAccount.withdraw(20)); // 80 console.log(firstAccount.withdraw(30)); // 50 -console.log(firstAccount.doBadThings); // undefined, this method is private +console.log(firstAccount.doBadThings); // undefined, this method is private const secondAccount = makeWithdraw(20); secondAccount.withdraw(30); // "Insufficient money" secondAccount.withdraw(20); // 0

For loop with var before ES6

-

We could see the following use of IIFE in some old code, before the introduction of the statements let and const -in ES6 and the block scope. With the statement var, we have only function scopes and the global scope. +

We could see the following use of IIFE in some old code, before the introduction of the statements let and const +in ES6 and the block scope. With the statement var, we have only function scopes and the global scope. Suppose we want to create 2 buttons with the texts Button 0 and Button 1 and we click them, we would like them to alert 0 and 1. The following code doesn't work:

-for (var i = 0; i < 2; i++) {
+for (var i = 0; i < 2; i++) {
   const button = document.createElement("button");
   button.innerText = "Button " + i;
   button.onclick = function () {
@@ -91,11 +91,11 @@ 

For loop with var before ES6

} console.log(i); // 2
-

When clicked, both Button 0 and Button 1 alert 2 because i is global, +

When clicked, both Button 0 and Button 1 alert 2 because i is global, with the last value 2. To fix this problem before ES6, we could use the IIFE pattern:

-for (var i = 0; i < 2; i++) {
+for (var i = 0; i < 2; i++) {
   const button = document.createElement("button");
   button.innerText = "Button " + i;
   button.onclick = (function (copyOfI) {
@@ -105,12 +105,12 @@ 

For loop with var before ES6

} console.log(i); // 2
-

When clicked, Buttons 0 and 1 alert 0 and 1. -The variable i is globally defined. +

When clicked, Buttons 0 and 1 alert 0 and 1. +The variable i is globally defined. Using the statement let, we could simply do:

-for (let i = 0; i < 2; i++) {
+for (let i = 0; i < 2; i++) {
   const button = document.createElement("button");
   button.innerText = "Button " + i;
   button.onclick = function () {
diff --git a/files/en-us/web/webdriver/capabilities/firefoxoptions/index.html b/files/en-us/web/webdriver/capabilities/firefoxoptions/index.html
index 9c5e2298b0fccf2..d4b1f6a80d6f11d 100644
--- a/files/en-us/web/webdriver/capabilities/firefoxoptions/index.html
+++ b/files/en-us/web/webdriver/capabilities/firefoxoptions/index.html
@@ -112,7 +112,7 @@ 
prefs (Preferences object)

Map of preference name to preference value, which can be a string, a boolean or an integer.

-
env (Env object)
+
env (Env object)

Map of environment variable name to environment variable value, both of which must be strings.

diff --git a/files/en-us/web/webdriver/index.html b/files/en-us/web/webdriver/index.html index a928fb26a2ec19a..edccef501ef5b27 100644 --- a/files/en-us/web/webdriver/index.html +++ b/files/en-us/web/webdriver/index.html @@ -51,7 +51,7 @@

Reference

Commands

-

Commands

+

Commands

{{ListSubpages("/en-US/docs/Web/WebDriver/Commands")}}

Types