Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: HTML Validation issues #4612

Merged
merged 1 commit into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions files/en-us/glossary/iife/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
<h2 id="use_cases">Use cases</h2>

<h3 id="avoid_polluting_the_global_namespace">Avoid polluting the global namespace</h3>
<p>Because our application could include many functions and global variables from different source files, it's
<p>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.</p>

<pre class="brush: js">
(function () {
// some initiation code
// some initiation code
let firstVariable;
let secondVariable;
let secondVariable;
})();

// firstVariable and secondVariable will be discarded after the function is executed.</pre>
Expand All @@ -49,7 +49,7 @@ <h3 id="the_module_pattern">The module pattern</h3>
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 {
Expand All @@ -60,28 +60,28 @@ <h3 id="the_module_pattern">The module pattern</h3>
} else {
return "Insufficient money";
}
},
},
}
})(balance);

const firstAccount = makeWithdraw(100); // "I will do bad things with your money"
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</pre>

<h3 id="for_loop_with_var_before_es6">For loop with var before ES6</h3>

<p>We could see the following use of IIFE in some old code, before the introduction of the statements <strong>let</strong> and <strong>const</strong>
in <strong>ES6</strong> and the block scope. With the statement <strong>var</strong>, we have only function scopes and the global scope.
<p>We could see the following use of IIFE in some old code, before the introduction of the statements <strong>let</strong> and <strong>const</strong>
in <strong>ES6</strong> and the block scope. With the statement <strong>var</strong>, 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:</p>

<pre class="brush: js">
for (var i = 0; i < 2; i++) {
for (var i = 0; i &lt; 2; i++) {
const button = document.createElement("button");
button.innerText = "Button " + i;
button.onclick = function () {
Expand All @@ -91,11 +91,11 @@ <h3 id="for_loop_with_var_before_es6">For loop with var before ES6</h3>
}
console.log(i); // 2</pre>

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

<pre class="brush: js">
for (var i = 0; i < 2; i++) {
for (var i = 0; i &lt; 2; i++) {
const button = document.createElement("button");
button.innerText = "Button " + i;
button.onclick = (function (copyOfI) {
Expand All @@ -105,12 +105,12 @@ <h3 id="for_loop_with_var_before_es6">For loop with var before ES6</h3>
}
console.log(i); // 2</pre>

<p>When clicked, Buttons 0 and 1 alert 0 and 1.
The variable <code>i</code> is globally defined.
<p>When clicked, Buttons 0 and 1 alert 0 and 1.
The variable <code>i</code> is globally defined.
Using the statement <strong>let</strong>, we could simply do:</p>

<pre class="brush: js">
for (let i = 0; i < 2; i++) {
for (let i = 0; i &lt; 2; i++) {
const button = document.createElement("button");
button.innerText = "Button " + i;
button.onclick = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ <h5 id="prefs_Preferences_object"><code>prefs</code> (Preferences object)</h5>
<p>Map of preference name to preference value, which can be a string, a boolean or an integer.</p>

<a id="env"></a>
<h5 id="env_Env_object"><code>env</code> (Env object)</a></h5>
<h5 id="env_Env_object"><code>env</code> (Env object)</h5>

<p>Map of environment variable name to environment variable value, both of which must be strings.</p>

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/webdriver/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h2 id="Reference">Reference</h2>
<div class="column-half">
<h3 id="Commands">Commands</h3>

<p><a href="/en-US/docs/Web/WebDriver/Commands"></a>Commands</a></p>
<p><a href="/en-US/docs/Web/WebDriver/Commands">Commands</a></p>
<p>{{ListSubpages("/en-US/docs/Web/WebDriver/Commands")}}</p>

<h3 id="Types">Types</h3>
Expand Down