From 08df46b4e907ce09bdcb87dca435936cc9f9ba2f Mon Sep 17 00:00:00 2001
From: OnkarRuikar <87750369+OnkarRuikar@users.noreply.github.com>
Date: Sat, 1 Oct 2022 08:36:23 +0530
Subject: [PATCH 1/3] Run Prettier on JS code fences, part 7
The PR focuses only on JS code fences.
Idea is to gradually prettify all the JS code fences before the full automation.
---
files/en-us/web/html/element/table/index.md | 12 ++--
.../web/html/global_attributes/is/index.md | 3 +-
.../web/html/global_attributes/nonce/index.md | 8 +--
.../index.md | 2 +-
files/en-us/web/http/cors/index.md | 16 ++---
.../en-us/web/manifest/share_target/index.md | 36 +++++------
files/en-us/web/media/autoplay_guide/index.md | 27 ++++----
.../web/media/formats/support_issues/index.md | 1 -
.../web/media/formats/video_codecs/index.md | 4 +-
files/en-us/web/privacy/index.md | 1 -
.../redirect_tracking_protection/index.md | 4 +-
.../add_to_home_screen/index.md | 26 ++++----
.../progressive_web_apps/installing/index.md | 1 -
.../web/progressive_web_apps/loading/index.md | 8 +--
.../responsive/mobile_first/index.md | 8 +--
.../web/security/types_of_attacks/index.md | 1 -
.../index.md | 2 +-
files/en-us/web/svg/attribute/k1/index.md | 2 +-
files/en-us/web/svg/attribute/k2/index.md | 2 +-
files/en-us/web/svg/attribute/k3/index.md | 2 +-
.../web/svg/attribute/pointer-events/index.md | 8 +--
.../web/svg/attribute/textlength/index.md | 16 +++--
.../web/svg/attribute/visibility/index.md | 8 ++-
files/en-us/web/svg/element/script/index.md | 19 ++----
.../web/svg/namespaces_crash_course/index.md | 24 +++++---
.../using_custom_elements/index.md | 61 ++++++++++---------
.../web_components/using_shadow_dom/index.md | 42 +++++++------
.../using_templates_and_slots/index.md | 20 +++---
.../index.md | 5 +-
.../advanced_example/index.md | 2 +-
.../basic_example/index.md | 1 -
.../javascript_xslt_bindings/index.md | 34 +++++------
32 files changed, 212 insertions(+), 194 deletions(-)
diff --git a/files/en-us/web/html/element/table/index.md b/files/en-us/web/html/element/table/index.md
index 3f77d2fd7279aaf..990780486f92a20 100644
--- a/files/en-us/web/html/element/table/index.md
+++ b/files/en-us/web/html/element/table/index.md
@@ -304,11 +304,11 @@ HTMLTableSectionElement.prototype.sort = function (cb) {
Array.from(this.rows)
.sort(cb)
.forEach((e) => this.appendChild(this.removeChild(e)));
-}
+};
-document.querySelector('table').tBodies[0].sort(
- (a, b) => a.textContent.localeCompare(b.textContent),
-);
+document
+ .querySelector("table")
+ .tBodies[0].sort((a, b) => a.textContent.localeCompare(b.textContent));
```
##### Result
@@ -351,7 +351,7 @@ The following example adds an event handler to every `
` element of every ` {
+ th.addEventListener("click", () => {
rows.sort((tr1, tr2) => {
const tr1Text = tr1.cells[cellIndex].textContent;
const tr2Text = tr2.cells[cellIndex].textContent;
diff --git a/files/en-us/web/html/global_attributes/is/index.md b/files/en-us/web/html/global_attributes/is/index.md
index 47d0739aae027dc..e5c120c18d4ce3b 100644
--- a/files/en-us/web/html/global_attributes/is/index.md
+++ b/files/en-us/web/html/global_attributes/is/index.md
@@ -28,12 +28,11 @@ class WordCount extends HTMLParagraphElement {
// Constructor contents omitted for brevity
// …
-
}
}
// Define the new element
-customElements.define('word-count', WordCount, { extends: 'p' });
+customElements.define("word-count", WordCount, { extends: "p" });
```
```html
diff --git a/files/en-us/web/html/global_attributes/nonce/index.md b/files/en-us/web/html/global_attributes/nonce/index.md
index 3939064ee592236..a49bb95b0a3a41d 100644
--- a/files/en-us/web/html/global_attributes/nonce/index.md
+++ b/files/en-us/web/html/global_attributes/nonce/index.md
@@ -35,8 +35,8 @@ From your web server, generate a random base64-encoded string of at least 128 bi
random number generator. Nonces should be generated differently each time the page loads (nonce only once!). For example, in nodejs:
```js
-const crypto = require('crypto');
-crypto.randomBytes(16).toString('base64');
+const crypto = require("crypto");
+crypto.randomBytes(16).toString("base64");
// '8IBTHwOdqNKAWeKl7plt8g=='
```
@@ -46,7 +46,7 @@ The nonce generated on your backend code should now be used for the inline scrip
```html
```
@@ -65,7 +65,7 @@ Content-Security-Policy: script-src 'nonce-8IBTHwOdqNKAWeKl7plt8g=='
For security reasons, the `nonce` content attribute is hidden (an empty string will be returned).
```js example-bad
-script.getAttribute('nonce'); // returns empty string
+script.getAttribute("nonce"); // returns empty string
```
The [`nonce`](/en-US/docs/Web/API/HTMLElement/nonce) property is the only way to access nonces:
diff --git a/files/en-us/web/http/browser_detection_using_the_user_agent/index.md b/files/en-us/web/http/browser_detection_using_the_user_agent/index.md
index 53f5e7d2b14a6aa..890244811645a4a 100644
--- a/files/en-us/web/http/browser_detection_using_the_user_agent/index.md
+++ b/files/en-us/web/http/browser_detection_using_the_user_agent/index.md
@@ -181,7 +181,7 @@ addEventListener(
() => {
orientationChanged = true;
},
- PASSIVE_LISTENER_OPTION,
+ PASSIVE_LISTENER_OPTION
);
addEventListener("resize", () =>
diff --git a/files/en-us/web/http/cors/index.md b/files/en-us/web/http/cors/index.md
index f37819aa2f3a62a..87d7cb730508ec1 100644
--- a/files/en-us/web/http/cors/index.md
+++ b/files/en-us/web/http/cors/index.md
@@ -97,9 +97,9 @@ For example, suppose web content at `https://foo.example` wishes to invoke conte
```js
const xhr = new XMLHttpRequest();
-const url = 'https://bar.other/resources/public-data/';
+const url = "https://bar.other/resources/public-data/";
-xhr.open('GET', url);
+xhr.open("GET", url);
xhr.onreadystatechange = someHandler;
xhr.send();
```
@@ -160,11 +160,11 @@ The following is an example of a request that will be preflighted:
```js
const xhr = new XMLHttpRequest();
-xhr.open('POST', 'https://bar.other/resources/post-here/');
-xhr.setRequestHeader('X-PINGOTHER', 'pingpong');
-xhr.setRequestHeader('Content-Type', 'text/xml');
+xhr.open("POST", "https://bar.other/resources/post-here/");
+xhr.setRequestHeader("X-PINGOTHER", "pingpong");
+xhr.setRequestHeader("Content-Type", "text/xml");
xhr.onreadystatechange = handler;
-xhr.send('Arun');
+xhr.send("Arun");
```
The example above creates an XML body to send with the `POST` request. Also, a non-standard HTTP `X-PINGOTHER` request header is set. Such headers are not part of HTTP/1.1, but are generally useful to web applications. Since the request uses a `Content-Type` of `text/xml`, and since a custom header is set, this request is preflighted.
@@ -288,11 +288,11 @@ In this example, content originally loaded from `https://foo.example` makes a si
```js
const invocation = new XMLHttpRequest();
-const url = 'https://bar.other/resources/credentialed-content/';
+const url = "https://bar.other/resources/credentialed-content/";
function callOtherDomain() {
if (invocation) {
- invocation.open('GET', url, true);
+ invocation.open("GET", url, true);
invocation.withCredentials = true;
invocation.onreadystatechange = handler;
invocation.send();
diff --git a/files/en-us/web/manifest/share_target/index.md b/files/en-us/web/manifest/share_target/index.md
index 577a0ac3bdb0053..700604133f05f59 100644
--- a/files/en-us/web/manifest/share_target/index.md
+++ b/files/en-us/web/manifest/share_target/index.md
@@ -63,7 +63,7 @@ A share target can be registered using the following `share_target` manifest mem
"params": {
"title": "name",
"text": "description",
- "url": "link",
+ "url": "link"
}
}
}
@@ -74,9 +74,9 @@ When a user selects your app in the system's share dialog, your PWA is launched,
The [URLSearchParams](/en-US/docs/Web/API/URLSearchParams) interface can be useful to handle the shared data in your application and do something with it.
```js
-const sharedName = url.searchParams.get('name');
-const sharedDescription = url.searchParams.get('description');
-const sharedLink = url.searchParams.get('link');
+const sharedName = url.searchParams.get("name");
+const sharedDescription = url.searchParams.get("description");
+const sharedLink = url.searchParams.get("link");
```
### Receiving share data using POST
@@ -90,7 +90,7 @@ If the share request includes one or multiple files or causes a side effect in y
"method": "POST",
"enctype": "multipart/form-data",
"params": {
- "url": "link",
+ "url": "link"
}
}
}
@@ -99,23 +99,25 @@ If the share request includes one or multiple files or causes a side effect in y
You can either handle `POST` share data using server-side code, or, to provide a better experience for offline users, a `fetch` event listener can be used to intercept the HTTP request which allows to access the data in a [service worker](/en-US/docs/Web/API/Service_Worker_API).
```js
-self.addEventListener('fetch', event => {
+self.addEventListener("fetch", (event) => {
// Regular requests not related to Web Share Target.
- if (event.request.method !== 'POST') {
+ if (event.request.method !== "POST") {
event.respondWith(fetch(event.request));
return;
}
- // Requests related to Web Share Target.
- event.respondWith((async () => {
- const formData = await event.request.formData();
- const link = formData.get('link') || '';
- // Instead of the original URL `/save-bookmark/`, redirect
- // the user to a URL returned by the `saveBookmark()`
- // function, for example, `/`.
- const responseUrl = await saveBookmark(link);
- return Response.redirect(responseUrl, 303);
- })());
+ // Requests related to Web Share Target.
+ event.respondWith(
+ (async () => {
+ const formData = await event.request.formData();
+ const link = formData.get("link") || "";
+ // Instead of the original URL `/save-bookmark/`, redirect
+ // the user to a URL returned by the `saveBookmark()`
+ // function, for example, `/`.
+ const responseUrl = await saveBookmark(link);
+ return Response.redirect(responseUrl, 303);
+ })()
+ );
});
```
diff --git a/files/en-us/web/media/autoplay_guide/index.md b/files/en-us/web/media/autoplay_guide/index.md
index 8edfba829985b8b..545c356007b09c6 100644
--- a/files/en-us/web/media/autoplay_guide/index.md
+++ b/files/en-us/web/media/autoplay_guide/index.md
@@ -147,16 +147,18 @@ You might use code like this to accomplish the job:
let startPlayPromise = videoElem.play();
if (startPlayPromise !== undefined) {
- startPlayPromise.then(() => {
- // Start whatever you need to do only after playback
- // has begun.
- }).catch((error) => {
- if (error.name === "NotAllowedError") {
- showPlayButton(videoElem);
- } else {
- // Handle a load or playback error
- }
- });
+ startPlayPromise
+ .then(() => {
+ // Start whatever you need to do only after playback
+ // has begun.
+ })
+ .catch((error) => {
+ if (error.name === "NotAllowedError") {
+ showPlayButton(videoElem);
+ } else {
+ // Handle a load or playback error
+ }
+ });
}
```
@@ -172,12 +174,13 @@ If you want to start playing the video after the first interaction with the page
```js
let playAttempt = setInterval(() => {
- videoElem.play()
+ videoElem
+ .play()
.then(() => {
clearInterval(playAttempt);
})
.catch((error) => {
- console.log('Unable to play the video, User has not interacted yet.');
+ console.log("Unable to play the video, User has not interacted yet.");
});
}, 3000);
```
diff --git a/files/en-us/web/media/formats/support_issues/index.md b/files/en-us/web/media/formats/support_issues/index.md
index 9d0278672d6bec7..9566e0237f0de35 100644
--- a/files/en-us/web/media/formats/support_issues/index.md
+++ b/files/en-us/web/media/formats/support_issues/index.md
@@ -16,7 +16,6 @@ tags:
- sound
---
-
One of the realities of working with audio and video presentation and manipulation on the web is that there are a number of media formats available, of varying degrees of popularity and with a variety of capabilities. The availability of choices is good for the user, in that they can choose the format that suits their needs best. There is a drawback, however: because there are so many to choose from, with so many different kinds of licenses and design principles involved, each web browser developer is left to its own devices when deciding which media file types and codecs to support.
This places a small, but reasonably easily overcome, burden on the web developer: to properly handle the situation when the user's browser can't handle a particular type of media. This guide covers techniques you can use to develop web content that meets your media needs while providing the most broadly compatible experience possible. Topics we will examine fallbacks, baseline media formats, and error handling practices that will let your content work in as many situations as possible.
diff --git a/files/en-us/web/media/formats/video_codecs/index.md b/files/en-us/web/media/formats/video_codecs/index.md
index 48cfab121bcd0b5..0ee342cc42ed4aa 100644
--- a/files/en-us/web/media/formats/video_codecs/index.md
+++ b/files/en-us/web/media/formats/video_codecs/index.md
@@ -2036,11 +2036,11 @@ Given the constraints on how close to lossless you can get, you might consider u
```js
const kbps = 1024;
-const Mbps = kbps*kbps;
+const Mbps = kbps * kbps;
const options = {
mimeType: 'video/webm; codecs="av01.2.19H.12.0.000.09.16.09.1, flac"',
- bitsPerSecond: 800*Mbps,
+ bitsPerSecond: 800 * Mbps,
};
let recorder = new MediaRecorder(sourceStream, options);
diff --git a/files/en-us/web/privacy/index.md b/files/en-us/web/privacy/index.md
index b74c0a857d3a3f1..434a78e10dde0b5 100644
--- a/files/en-us/web/privacy/index.md
+++ b/files/en-us/web/privacy/index.md
@@ -16,7 +16,6 @@ tags:
- personal
---
-
As users use the web for more and more of their daily tasks, more of their private or personally-identifying information they share, ideally only with sites they trust. Cooperation among web content, the web browser, and the web server is needed to achieve as much privacy and information security as possible. In this article, we examine how to create web content that minimizes the risk of users' personal information or imagery being obtained unexpectedly by third parties.
## Security and privacy defined
diff --git a/files/en-us/web/privacy/redirect_tracking_protection/index.md b/files/en-us/web/privacy/redirect_tracking_protection/index.md
index 23075eb025373d4..5fe692acc747506 100644
--- a/files/en-us/web/privacy/redirect_tracking_protection/index.md
+++ b/files/en-us/web/privacy/redirect_tracking_protection/index.md
@@ -73,7 +73,9 @@ Different log levels can be set via the `privacy.purge_trackers.logging.level` p
For debugging purposes, it's easiest to trigger storage clearing by triggering the service directly via the [Browser Console command line](https://firefox-source-docs.mozilla.org/devtools-user/browser_console/index.html#browser-console-command-line). Note that this is different from the normal [Web Console](https://firefox-source-docs.mozilla.org/devtools-user/web_console/index.html) you might use to debug a website, and requires the `devtools.chrome.enabled` pref to be set to `true` to use it interactively. Once you've enabled the Browser Console you can trigger storage clearing by running the following command:
```js
-await Components.classes["@mozilla.org/purge-tracker-service;1"].getService(Components.interfaces.nsIPurgeTrackerService).purgeTrackingCookieJars()
+await Components.classes["@mozilla.org/purge-tracker-service;1"]
+ .getService(Components.interfaces.nsIPurgeTrackerService)
+ .purgeTrackingCookieJars();
```
The time until user interaction permissions expire can be set to a lower amount using the `privacy.userInteraction.expiration` pref. Note that you will have to set this pref before visiting the sites you want to test — it will not apply retroactively.
diff --git a/files/en-us/web/progressive_web_apps/add_to_home_screen/index.md b/files/en-us/web/progressive_web_apps/add_to_home_screen/index.md
index 5c21f62c8954f65..a6b7cf322f13e67 100644
--- a/files/en-us/web/progressive_web_apps/add_to_home_screen/index.md
+++ b/files/en-us/web/progressive_web_apps/add_to_home_screen/index.md
@@ -156,35 +156,35 @@ At the bottom of our [`index.js` file](https://github.com/mdn/pwa-examples/blob/
```js
let deferredPrompt;
-const addBtn = document.querySelector('.add-button');
-addBtn.style.display = 'none';
+const addBtn = document.querySelector(".add-button");
+addBtn.style.display = "none";
```
We hide the button initially because the PWA will not be available for install until it follows the A2HS criteria. When this happens, supporting browsers will fire a `beforeinstallprompt` event. We can then use a handler like the one below to handle the installation:
```js
-window.addEventListener('beforeinstallprompt', (e) => {
+window.addEventListener("beforeinstallprompt", (e) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
// Update UI to notify the user they can add to home screen
- addBtn.style.display = 'block';
+ addBtn.style.display = "block";
- addBtn.addEventListener('click', (e) => {
+ addBtn.addEventListener("click", (e) => {
// hide our user interface that shows our A2HS button
- addBtn.style.display = 'none';
+ addBtn.style.display = "none";
// Show the prompt
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult) => {
- if (choiceResult.outcome === 'accepted') {
- console.log('User accepted the A2HS prompt');
- } else {
- console.log('User dismissed the A2HS prompt');
- }
- deferredPrompt = null;
- });
+ if (choiceResult.outcome === "accepted") {
+ console.log("User accepted the A2HS prompt");
+ } else {
+ console.log("User dismissed the A2HS prompt");
+ }
+ deferredPrompt = null;
+ });
});
});
```
diff --git a/files/en-us/web/progressive_web_apps/installing/index.md b/files/en-us/web/progressive_web_apps/installing/index.md
index e53db2ef8ab168c..5ed74babfc349f9 100644
--- a/files/en-us/web/progressive_web_apps/installing/index.md
+++ b/files/en-us/web/progressive_web_apps/installing/index.md
@@ -20,7 +20,6 @@ tags:
- Web
---
-
Web application installation is a feature available in modern browsers that allows users to choose to easily and conveniently "install" a web application on their device so they can access it in the same way they would any other installed app. Depending on the device and features of the operating system and browser, this can result in what is essentially a fully featured application (for example, using [WebAPK](https://web.dev/webapks/) on Android) or as a shortcut added to their device's screen. This guide explains how installation is performed, what it means, and what you need to do as a developer to let your users take advantage of it.
## Why installation?
diff --git a/files/en-us/web/progressive_web_apps/loading/index.md b/files/en-us/web/progressive_web_apps/loading/index.md
index 59404fe7c26e169..0f69361758d4015 100644
--- a/files/en-us/web/progressive_web_apps/loading/index.md
+++ b/files/en-us/web/progressive_web_apps/loading/index.md
@@ -82,11 +82,11 @@ Those images will be loaded via JavaScript _after_ the site finishes building th
The `app.js` file processes the `data-src` attributes like so:
```js
-let imagesToLoad = document.querySelectorAll('img[data-src]');
+let imagesToLoad = document.querySelectorAll("img[data-src]");
const loadImages = (image) => {
- image.setAttribute('src', image.getAttribute('data-src'));
+ image.setAttribute("src", image.getAttribute("data-src"));
image.onload = () => {
- image.removeAttribute('data-src');
+ image.removeAttribute("data-src");
};
};
```
@@ -145,7 +145,7 @@ This is a progressive enhancement to the previously working example — [Interse
Here's what the relevant code looks like:
```js
-if ('IntersectionObserver' in window) {
+if ("IntersectionObserver" in window) {
const observer = new IntersectionObserver((items, observer) => {
items.forEach((item) => {
if (item.isIntersecting) {
diff --git a/files/en-us/web/progressive_web_apps/responsive/mobile_first/index.md b/files/en-us/web/progressive_web_apps/responsive/mobile_first/index.md
index 6a4568e7a6ac99e..dfe2dcf9656199c 100644
--- a/files/en-us/web/progressive_web_apps/responsive/mobile_first/index.md
+++ b/files/en-us/web/progressive_web_apps/responsive/mobile_first/index.md
@@ -250,8 +250,8 @@ I put Modernizr inside my `js/lib` directory, then included it by putting the fo
With Modernizr in place, we can now use the following JS block to test whether media queries are supported, and if not, to load in [respond.js](https://github.com/scottjehl/Respond), Scott Jehl's `matchMedia` and media query polyfill.
```js
-if (!Modernizr.mq('only all')) {
- require('respond');
+if (!Modernizr.mq("only all")) {
+ require("respond");
}
```
@@ -259,7 +259,7 @@ if (!Modernizr.mq('only all')) {
```js
if (window.matchMedia("(min-width: 481px)").matches) {
- require('three');
+ require("three");
}
```
@@ -270,7 +270,7 @@ We can, therefore, save the bandwidth for browsers that don't need it.
Back to Modernizr! The reason why it is so useful is that it provides a mechanism to selectively serve both CSS and JavaScript. Modernizr stores the results of all its feature tests as classes on the HTML element. For example, the Modernizr in our example app is testing for multiple background image and rgba support. When they are not supported, the `` tag looks like this:
```html
-
+
```
When these are present, we can serve alternative styling rules to provide sensible fallbacks using descendant selectors — see the following in my code.
diff --git a/files/en-us/web/security/types_of_attacks/index.md b/files/en-us/web/security/types_of_attacks/index.md
index dc6d4f1ef47180e..7cbbe2e6a956ee6 100644
--- a/files/en-us/web/security/types_of_attacks/index.md
+++ b/files/en-us/web/security/types_of_attacks/index.md
@@ -3,7 +3,6 @@ title: Types of attacks
slug: Web/Security/Types_of_attacks
---
-
This article describes various types of security attacks and techniques to mitigate them.
## Click-jacking
diff --git a/files/en-us/web/svg/applying_svg_effects_to_html_content/index.md b/files/en-us/web/svg/applying_svg_effects_to_html_content/index.md
index d317ae4603b9510..67b9ac0aee45998 100644
--- a/files/en-us/web/svg/applying_svg_effects_to_html_content/index.md
+++ b/files/en-us/web/svg/applying_svg_effects_to_html_content/index.md
@@ -121,7 +121,7 @@ You can make changes to the SVG in real time and see them immediately affect the
```js
function toggleRadius() {
const circle = document.getElementById("circle");
- circle.r.baseVal.value = 0.40 - circle.r.baseVal.value;
+ circle.r.baseVal.value = 0.4 - circle.r.baseVal.value;
}
```
diff --git a/files/en-us/web/svg/attribute/k1/index.md b/files/en-us/web/svg/attribute/k1/index.md
index 09c5c4ed2263ff9..f2181613d77b4fd 100644
--- a/files/en-us/web/svg/attribute/k1/index.md
+++ b/files/en-us/web/svg/attribute/k1/index.md
@@ -15,7 +15,7 @@ The **`k1`** attribute defines one of the values to be used within the `arithmet
The pixel composition is computed using the following formula:
```js
-result = k1*i1*i2 + k2*i1 + k3*i2 + k4
+result = k1 * i1 * i2 + k2 * i1 + k3 * i2 + k4;
```
You can use this attribute with the following SVG elements:
diff --git a/files/en-us/web/svg/attribute/k2/index.md b/files/en-us/web/svg/attribute/k2/index.md
index b46e580b745c964..50239d5a18dcbfe 100644
--- a/files/en-us/web/svg/attribute/k2/index.md
+++ b/files/en-us/web/svg/attribute/k2/index.md
@@ -15,7 +15,7 @@ The **`k2`** attribute defines one of the values to be used within the `arithmet
The pixel composition is computed using the following formula:
```js
-result = k1*i1*i2 + k2*i1 + k3*i2 + k4
+result = k1 * i1 * i2 + k2 * i1 + k3 * i2 + k4;
```
You can use this attribute with the following SVG elements:
diff --git a/files/en-us/web/svg/attribute/k3/index.md b/files/en-us/web/svg/attribute/k3/index.md
index b56caca32a1b663..ca4b52c2efecfd6 100644
--- a/files/en-us/web/svg/attribute/k3/index.md
+++ b/files/en-us/web/svg/attribute/k3/index.md
@@ -15,7 +15,7 @@ The **`k3`** attribute defines one of the values to be used within the `arithmet
The pixel composition is computed using the following formula:
```js
-result = k1*i1*i2 + k2*i1 + k3*i2 + k4
+result = k1 * i1 * i2 + k2 * i1 + k3 * i2 + k4;
```
You can use this attribute with the following SVG elements:
diff --git a/files/en-us/web/svg/attribute/pointer-events/index.md b/files/en-us/web/svg/attribute/pointer-events/index.md
index 75b26ff77e38866..a13b2d1a3539e39 100644
--- a/files/en-us/web/svg/attribute/pointer-events/index.md
+++ b/files/en-us/web/svg/attribute/pointer-events/index.md
@@ -70,17 +70,17 @@ svg {
```
```js
-window.addEventListener('mouseup', (e) => {
+window.addEventListener("mouseup", (e) => {
// Let's pick a random color between #000000 and #FFFFFF
- const color = Math.round(Math.random() * 0xFFFFFF);
+ const color = Math.round(Math.random() * 0xffffff);
// Let's format the color to fit CSS requirements
- const fill = `#${color.toString(16).padStart(6, '0')}`;
+ const fill = `#${color.toString(16).padStart(6, "0")}`;
// Let's apply our color in the
// element we actually clicked on
e.target.style.fill = fill;
-})
+});
```
{{EmbedLiveSample("Example", '100%', 150)}}
diff --git a/files/en-us/web/svg/attribute/textlength/index.md b/files/en-us/web/svg/attribute/textlength/index.md
index 9d6da4e75acc827..ff543ede9266520 100644
--- a/files/en-us/web/svg/attribute/textlength/index.md
+++ b/files/en-us/web/svg/attribute/textlength/index.md
@@ -144,11 +144,17 @@ const baseLength = Math.floor(textElement.textLength.baseVal.value);
widthSlider.value = baseLength;
-widthSlider.addEventListener("input", (event) => {
- textElement.textLength.baseVal.newValueSpecifiedUnits(
- SVGLength.SVG_LENGTHTYPE_PX, widthSlider.valueAsNumber);
- widthDisplay.innerText = widthSlider.value;
-}, false);
+widthSlider.addEventListener(
+ "input",
+ (event) => {
+ textElement.textLength.baseVal.newValueSpecifiedUnits(
+ SVGLength.SVG_LENGTHTYPE_PX,
+ widthSlider.valueAsNumber
+ );
+ widthDisplay.innerText = widthSlider.value;
+ },
+ false
+);
widthSlider.dispatchEvent(new Event("input"));
```
diff --git a/files/en-us/web/svg/attribute/visibility/index.md b/files/en-us/web/svg/attribute/visibility/index.md
index 7eb7940cab40f59..d0fb0d2c99fd121 100644
--- a/files/en-us/web/svg/attribute/visibility/index.md
+++ b/files/en-us/web/svg/attribute/visibility/index.md
@@ -116,8 +116,12 @@ button {
```js
const button = document.querySelector("button");
button.addEventListener("click", (evt) => {
- button.querySelector("svg > path:nth-of-type(1)").classList.toggle("invisible");
- button.querySelector("svg > path:nth-of-type(2)").classList.toggle("invisible");
+ button
+ .querySelector("svg > path:nth-of-type(1)")
+ .classList.toggle("invisible");
+ button
+ .querySelector("svg > path:nth-of-type(2)")
+ .classList.toggle("invisible");
});
```
diff --git a/files/en-us/web/svg/element/script/index.md b/files/en-us/web/svg/element/script/index.md
index 137a7ce736d83ae..45b862139a5650b 100644
--- a/files/en-us/web/svg/element/script/index.md
+++ b/files/en-us/web/svg/element/script/index.md
@@ -19,20 +19,13 @@ The SVG `script` element allows to add scripts to an SVG document.
```html