Skip to content

Commit

Permalink
Merge branch 'main' into ff117relnote_2dcontext_getcontextattr
Browse files Browse the repository at this point in the history
  • Loading branch information
Elchi3 authored Aug 7, 2023
2 parents b5d2d56 + 2f07f09 commit e583ae5
Show file tree
Hide file tree
Showing 197 changed files with 1,441 additions and 968 deletions.
146 changes: 146 additions & 0 deletions .github/workflows/pr-check-lint_content.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Lint and review content files

on:
pull_request_target:
branches:
- main
paths:
- .nvmrc
- "*.md"
- "files/**/*.md"

permissions:
pull-requests: write

jobs:
lint-and-review-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout BASE
uses: actions/checkout@v3

- name: Checkout HEAD
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
path: pr_head

- name: Get changed content from HEAD
run: |
git config --global user.email "[email protected]"
git config --global user.name "mdn-bot"
rm -r files *.md
mv pr_head/files pr_head/*.md .
rm -r pr_head
# To avoid contents of PR getting into the diff that we are going to generate
# after running the linters, here we make a dummy commit.
# Note, this commit is not getting pushed.
git commit -am "Code from PR head"
- name: Get changed files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
# Use the GitHub API to get the list of changed files
# documentation: https://docs.github.com/rest/commits/commits#compare-two-commits
DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \
--jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename')
# filter out files that are not markdown
DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^files/.*\.md$" | xargs)
echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: yarn

- name: Install all yarn packages
run: yarn --frozen-lockfile
env:
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Lint and format markdown files
run: |
# Generate random delimiter
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
EOF="$(openssl rand -hex 8)"
files_to_lint="${{ env.DIFF_DOCUMENTS }}"
echo "Running markdownlint --fix"
MD_LINT_FAILED=false
MD_LINT_LOG=$(yarn markdownlint-cli2 --fix ${files_to_lint} 2>&1) || MD_LINT_FAILED=true
echo "MD_LINT_LOG<<${EOF}" >> $GITHUB_ENV
echo "${MD_LINT_LOG}" >> $GITHUB_ENV
echo "${EOF}" >> $GITHUB_ENV
echo "MD_LINT_FAILED=${MD_LINT_FAILED}" >> $GITHUB_ENV
echo "Linting front-matter"
FM_LINT_FAILED=false
FM_LINT_LOG=$(node scripts/front-matter_linter.js --fix true ${files_to_lint} 2>&1) || FM_LINT_FAILED=true
echo "FM_LINT_LOG<<${EOF}" >> $GITHUB_ENV
echo "${FM_LINT_LOG}" >> $GITHUB_ENV
echo "${EOF}" >> $GITHUB_ENV
echo "FM_LINT_FAILED=${FM_LINT_FAILED}" >> $GITHUB_ENV
echo "Running Prettier"
yarn prettier -w ${files_to_lint}
if [[ -n $(git diff) ]]; then
echo "FILES_MODIFIED=true" >> $GITHUB_ENV
fi
# info for troubleshooting
echo MD_LINT_FAILED=${MD_LINT_FAILED}
echo FM_LINT_FAILED=${FM_LINT_FAILED}
git diff
- name: Setup reviewdog
if: env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true'
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest

- name: Suggest changes using diff
if: env.FILES_MODIFIED == 'true'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TMPFILE=$(mktemp)
git diff >"${TMPFILE}"
git stash -u && git stash drop
reviewdog \
-name="mdn-linter" \
-f=diff \
-f.diff.strip=1 \
-reporter=github-pr-review < "${TMPFILE}"
- name: Add reviews for markdownlint errors
if: env.MD_LINT_FAILED == 'true'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "${{ env.MD_LINT_LOG }}" | \
reviewdog \
-efm="%f:%l:%c %m" \
-efm="%f:%l %m" \
-name="markdownlint" \
-diff="git diff" \
-reporter="github-pr-review"
- name: Fail if any issues pending
if: env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true' || env.FM_LINT_FAILED == 'true'
run: |
echo -e "\nLogs from markdownlint:"
echo "${{ env.MD_LINT_LOG }}"
echo -e "\nLogs from front-matter linter:"
echo "${{ env.FM_LINT_LOG }}"
echo -e "\nPlease fix all the linting issues mentioned in above logs and in the review comments."
exit 1
50 changes: 0 additions & 50 deletions .github/workflows/pr-check_markdownlint.yml

This file was deleted.

6 changes: 4 additions & 2 deletions files/en-us/glossary/hoisting/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ page-type: glossary-definition

{{GlossarySidebar}}

JavaScript **Hoisting** refers to the process whereby the interpreter appears to move the _declaration_ of functions, variables or classes to the top of their scope, prior to execution of the code.
JavaScript **Hoisting** refers to the process whereby the interpreter appears to move the _declaration_ of functions, variables, classes, or imports to the top of their scope, prior to execution of the code.

_Hoisting_ is not a term normatively defined in the ECMAScript specification. The spec does define a group of declarations as [_HoistableDeclaration_](https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#prod-HoistableDeclaration), but this only includes [`function`](/en-US/docs/Web/JavaScript/Reference/Statements/function), [`function*`](/en-US/docs/Web/JavaScript/Reference/Statements/function*), [`async function`](/en-US/docs/Web/JavaScript/Reference/Statements/async_function), and [`async function*`](/en-US/docs/Web/JavaScript/Reference/Statements/async_function*) declarations. Hoisting is often considered a feature of [`var`](/en-US/docs/Web/JavaScript/Reference/Statements/var) declarations as well, although in a different way. In colloquial terms, any of the following behaviors may be regarded as hoisting:

1. Being able to use a variable's value in its scope before the line it is declared. ("Value hoisting")
2. Being able to reference a variable in its scope before the line it is declared, without throwing a {{jsxref("ReferenceError")}}, but the value is always [`undefined`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined). ("Declaration hoisting")
3. The declaration of the variable causes behavior changes in its scope before the line in which it is declared.
4. The side effects of a declaration are produced before evaluating the rest of the code that contains it.

The four function declarations above are hoisted with type 1 behavior; `var` declaration is hoisted with type 2 behavior; [`let`](/en-US/docs/Web/JavaScript/Reference/Statements/let), [`const`](/en-US/docs/Web/JavaScript/Reference/Statements/const), and [`class`](/en-US/docs/Web/JavaScript/Reference/Statements/class) declarations (also collectively called _lexical declarations_) are hoisted with type 3 behavior.
The four function declarations above are hoisted with type 1 behavior; `var` declaration is hoisted with type 2 behavior; [`let`](/en-US/docs/Web/JavaScript/Reference/Statements/let), [`const`](/en-US/docs/Web/JavaScript/Reference/Statements/const), and [`class`](/en-US/docs/Web/JavaScript/Reference/Statements/class) declarations (also collectively called _lexical declarations_) are hoisted with type 3 behavior; [`import`](/en-US/docs/Web/JavaScript/Reference/Statements/import) declarations are hoisted with type 1 and type 4 behavior.

Some prefer to see `let`, `const`, and `class` as non-hoisting, because the [temporal dead zone](/en-US/docs/Web/JavaScript/Reference/Statements/let#temporal_dead_zone_tdz) strictly forbids any use of the variable before its declaration. This dissent is fine, since hoisting is not a universally-agreed term. However, the temporal dead zone can cause other observable changes in its scope, which suggests there's some form of hoisting:

Expand Down Expand Up @@ -44,6 +45,7 @@ For more information on hoisting, see:
- `var`/`let`/`const` hoisting — [Grammar and types guide](/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#variable_hoisting)
- `function` hoisting — [Functions guide](/en-US/docs/Web/JavaScript/Guide/Functions#function_hoisting)
- `class` hoisting — [Classes guide](/en-US/docs/Web/JavaScript/Guide/Using_classes#class_declaration_hoisting)
- `import` hoisting — [JavaScript modules](/en-US/docs/Web/JavaScript/Guide/Modules#import_declarations_are_hoisted)

## See also

Expand Down
12 changes: 6 additions & 6 deletions files/en-us/glossary/prefetch/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Prefetching might be used, for example, to fetch the page resources linked by a
Resources should be prefetched based on how likely it is that they will be needed in a future navigation.
Browsers can infer this automatically for some resources, such as the current URL in the address bar.

Browsers will also prefetch content for [`<link>`](/en-US/docs/Web/HTML/Element/link) elements that have the [`rel="prefetch"`](/en-US/docs/Web/HTML/Attributes/rel/prefetch) attribute.
Browsers will also prefetch content for [`<link>`](/en-US/docs/Web/HTML/Element/link) elements with the [`rel="prefetch"`](/en-US/docs/Web/HTML/Attributes/rel/prefetch) attribute.
This allows developers to hint to the browser the likely navigation from the current page.
Note that only these links are prefetched (so `<a>` elements are not), and that they are fetched at lower priority that resources used by the current page, including elements with `fetchPriority="low"`.
Note that only these links are prefetched (so `<a>` elements are not), and they are fetched at a lower priority than resources used by the current page, including elements with `fetchPriority="low"`.

Prefetching can be used to fetch both HTML and sub-resources for a possible next navigation. A common use case is to have a simple website landing page that fetches more "heavy-weight" resources used by the rest of the site.

Expand All @@ -26,17 +26,17 @@ Prefetching can be used to fetch both HTML and sub-resources for a possible next
<link rel="prefetch" href="https://example.com/landing-page" />
```

The fetch request for a `prefetch` operation results an HTTP Request that includes the HTTP header [`Sec-Purpose: prefetch`](/en-US/docs/Web/HTTP/Headers/Sec-Purpose), which a server might use to change the cache timeouts for the resources, or perform other special handling.
The fetch request for a `prefetch` operation results in an HTTP Request that includes the HTTP header [`Sec-Purpose: prefetch`](/en-US/docs/Web/HTTP/Headers/Sec-Purpose). A server might use this header to change the cache timeouts for the resources, or perform other special handling.
The request should also include the {{HTTPHeader("Sec-Fetch-Dest")}} header with the value set to `empty`.
The {{HTTPHeader("Accept")}} header in the request should match the value used for normal navigation requests, so that the browser can find the matching cached resources following navigation.
If a response is returned, it is cached with the request in the HTTP cache.
The {{HTTPHeader("Accept")}} header in the request should match the value used for normal navigation requests. This allows the browser to find the matching cached resources following navigation.
If a response is returned, it gets cached with the request in the HTTP cache.

> **Note:** Browser vendors are currently aligning around the HTTP headers that are sent, and may use different headers and values.
> The best place to track specification compliance is the [`Sec-Purpose`](/en-US/docs/Web/HTTP/Headers/Sec-Purpose) compatibility table.
### DNS Prefetching

[DNS prefetching](/en-US/docs/Web/HTML/Attributes/rel/dns-prefetch) resolves domain names in advance thereby speeding up load times by reducing the time associated with domain lookup at request time.
[DNS prefetching](/en-US/docs/Web/HTML/Attributes/rel/dns-prefetch) resolves domain names in advance, speeding up load times by reducing the time associated with domain lookup at request time.

```html
<link rel="dns-prefetch" href="https://example.com/" />
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/learn/javascript/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ This topic contains the following modules, in a suggested order for working thro
- [Learn JavaScript](https://learnjavascript.online/)
- : An excellent resource for aspiring web developers — Learn JavaScript in an interactive environment, with short lessons and interactive tests, guided by automated assessment. The first 40 lessons are free.
- [Coding math](https://www.youtube.com/user/codingmath)
- : An excellent series of video tutorials to teach the math you need to understand to be an effective programmer, by [Keith Peters](https://twitter.com/bit101).
- : An excellent series of video tutorials to teach the math you need to understand to be an effective programmer, by [Keith Peters](https://www.bit-101.com/blog/about-me/).
2 changes: 1 addition & 1 deletion files/en-us/learn/performance/css/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Browsers may set up optimizations before an element is actually changed. These k

## Optimizing for render blocking

CSS can scope styles to particular conditions with media queries. Media queries are important for a responsive web design and help us optimize a critical rendering path. The browser blocks rendering until it parses all of these styles but will not block rendering on styles it knows it will not use, such the print stylesheets. By splitting the CSS into multiple files based on media queries, you can prevent render blocking during download of unused CSS. To create a non-blocking CSS link, move the not-immediately used styles, such as print styles, into separate file, add a [`<link>`](/en-US/docs/Web/HTML/Element/link) to the HTML mark up, and add a media query, in this case stating it's a print stylesheet.
CSS can scope styles to particular conditions with media queries. Media queries are important for a responsive web design and help us optimize a critical rendering path. The browser blocks rendering until it parses all of these styles but will not block rendering on styles it knows it will not use, such as the print stylesheets. By splitting the CSS into multiple files based on media queries, you can prevent render blocking during download of unused CSS. To create a non-blocking CSS link, move the not-immediately used styles, such as print styles, into separate file, add a [`<link>`](/en-US/docs/Web/HTML/Element/link) to the HTML mark up, and add a media query, in this case stating it's a print stylesheet.

```html
<!-- Loading and parsing styles.css is render-blocking -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ page-type: mdn-community-guide

{{MDNSidebar}}

Since December 14th 2020, MDN has been running on the new GitHub-based [Yari platform](https://github.com/mdn/yari). This has a lot of advantages for MDN, but we've needed to make radical changes to the way in which we handle localization. This is because we've ended up with a lot of unmaintained and out-of-date content in our non-en-US locales, and we want to manage it better in the future.
Since December 14th 2020, MDN has been running on the new GitHub-based [Yari platform](https://github.com/mdn/yari). This has a lot of advantages for MDN, but we've needed to make radical changes to the way in which we handle localization. This is because we've ended up with a lot of unmaintained and out-of-date content in our non-English locales, and we want to manage it better in the future.

We have frozen all localized content (meaning that we won't accept any edits to it; it'll be read-only), EXCEPT for the below locales — these locales have dedicated teams taking responsibility for maintaining them.
We have archived all locales, EXCEPT for the ones listed below, meaning that they are read-only on GitHub and cannot be viewed on MDN. The active locales have dedicated teams taking responsibility for maintaining them.

## Active locales
## How to contribute

If you want to contribute to one of the existing active locales, check out the [mdn/translated-content GitHub repository](https://github.com/mdn/translated-content). This repository contains all of the localized documents for all active locales, as well as issue tracking. We recommend reading the [translation guide](https://github.com/mdn/translated-content/tree/main/docs) first.

> **Note:** If you want to contribute to one of the existing active locales get in touch with one of the active members listed below, or [contact us](/en-US/docs/MDN/Community/Communication_channels) if you have any questions.
If you need help or have any questions, feel free to get in touch with one of the active members or communities listed below, or [contact us](/en-US/docs/MDN/Community/Communication_channels).

## Active locales

### Brazilian Portuguese (pt-BR)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ For methods that accept an arbitrary number of parameters, the syntax block is w
unshift()
unshift(element0)
unshift(element0, element1)
unshift(element0, element1, /* … ,*/ elementN)
unshift(element0, element1, /* …, */ elementN)
```

#### Parameters section
Expand Down
Loading

0 comments on commit e583ae5

Please sign in to comment.