aboutsummaryrefslogtreecommitdiffstats
path: root/docs/content/doc/developers
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-06-02 12:22:42 +0800
committerGitHub <noreply@github.com>2022-06-02 00:22:42 -0400
commit6171ea7d318c0ca8714bc6efd6a97ea4b495eb6d (patch)
tree9f6a0560cbca1cee7c98af4bdd3570509e5f2345 /docs/content/doc/developers
parent8aaba65eeeb7b312a312919c7ccd513acc301f6d (diff)
downloadgitea-6171ea7d318c0ca8714bc6efd6a97ea4b495eb6d.tar.gz
gitea-6171ea7d318c0ca8714bc6efd6a97ea4b495eb6d.zip
update documents (#19868)
Diffstat (limited to 'docs/content/doc/developers')
-rw-r--r--docs/content/doc/developers/guidelines-frontend.md46
1 files changed, 1 insertions, 45 deletions
diff --git a/docs/content/doc/developers/guidelines-frontend.md b/docs/content/doc/developers/guidelines-frontend.md
index 874896c5dc..01d44596b2 100644
--- a/docs/content/doc/developers/guidelines-frontend.md
+++ b/docs/content/doc/developers/guidelines-frontend.md
@@ -64,7 +64,7 @@ Discouraged implementations:
Only mark a function as `async` if and only if there are `await` calls
or `Promise` returns inside the function.
-It's not recommended to use `async` event listeners, which may lead to problems.
+It's not recommended to use `async` event listeners, which may lead to problems.
The reason is that the code after await is executed outside the event dispatch.
Reference: https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventdefault.md
@@ -73,50 +73,6 @@ it's recommended to use `const _promise = asyncFoo()` to tell readers
that this is done by purpose, we want to call the async function and ignore the Promise.
Some lint rules and IDEs also have warnings if the returned Promise is not handled.
-#### DOM Event Listener
-
-```js
-el.addEventListener('click', (e) => {
- (async () => {
- await asyncFoo(); // recommended
- // then we shound't do e.preventDefault() after await, no effect
- })();
-
- const _promise = asyncFoo(); // recommended
-
- e.preventDefault(); // correct
-});
-
-el.addEventListener('async', async (e) => { // not recommended but acceptable
- e.preventDefault(); // acceptable
- await asyncFoo(); // skip out event dispatch
- e.preventDefault(); // WRONG
-});
-```
-
-#### jQuery Event Listener
-
-```js
-$('#el').on('click', (e) => {
- (async () => {
- await asyncFoo(); // recommended
- // then we shound't do e.preventDefault() after await, no effect
- })();
-
- const _promise = asyncFoo(); // recommended
-
- e.preventDefault(); // correct
- return false; // correct
-});
-
-$('#el').on('click', async (e) => { // not recommended but acceptable
- e.preventDefault(); // acceptable
- return false; // WRONG, jQuery expects the returned value is a boolean, not a Promise
- await asyncFoo(); // skip out event dispatch
- return false; // WRONG
-});
-```
-
### HTML Attributes and `dataset`
We forbid `dataset` usage, its camel-casing behaviour makes it hard to grep for attributes. However there are still some special cases, so the current guideline is: