- Notifications
You must be signed in to change notification settings - Fork924
Добавление раздела: WeakRef & FinalizationRegistry#1899
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
6 commits Select commitHold shift + click to select a range
ab51673 Add WeakRef and FinalizationRegistry article
WOLFRIENDc5a41ec Apply suggestions from code review
WOLFRIEND632c80a Fix typos and added improvements according to the suggested edits
WOLFRIENDaf1ce6d Обновленные SVG, правки статьи, интерактивных демо
Alexandre8872f1fd62 Fix typos and added improvements according to the suggested edits
WOLFRIEND90ddd15 Мелкие правки, изображения, SVG
Alexandre887File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
448 changes: 448 additions & 0 deletions1-js/99-js-misc/09-weakref-finalizationregistry/article.md
Large diffs are not rendered by default.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions1-js/99-js-misc/09-weakref-finalizationregistry/weakref-dom.view/index.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| .app { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 16px; | ||
| } | ||
| .start-messages { | ||
| width: fit-content; | ||
| } | ||
| .window { | ||
| width: 100%; | ||
| border: 2px solid #464154; | ||
| overflow: hidden; | ||
| } | ||
| .window__header { | ||
| position: sticky; | ||
| padding: 8px; | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| background-color: #736e7e; | ||
| } | ||
| .window__title { | ||
| margin: 0; | ||
| font-size: 24px; | ||
| font-weight: 700; | ||
| color: white; | ||
| letter-spacing: 1px; | ||
| } | ||
| .window__button { | ||
| padding: 4px; | ||
| background: #4f495c; | ||
| outline: none; | ||
| border: 2px solid #464154; | ||
| color: white; | ||
| font-size: 16px; | ||
| cursor: pointer; | ||
| } | ||
| .window__body { | ||
| height: 250px; | ||
| padding: 16px; | ||
| overflow: scroll; | ||
| background-color: #736e7e33; | ||
| } |
27 changes: 27 additions & 0 deletions1-js/99-js-misc/09-weakref-finalizationregistry/weakref-dom.view/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <!DOCTYPE HTML> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <link rel="stylesheet" href="index.css"> | ||
| </head> | ||
| <body> | ||
| <div class="app"> | ||
| <button class="start-messages">Начать отправку сообщений</button> | ||
| <div class="window"> | ||
| <div class="window__header"> | ||
| <p class="window__title">Сообщения:</p> | ||
| <button class="window__button">Закрыть</button> | ||
| </div> | ||
| <div class="window__body"> | ||
| Нет сообщений. | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <script type="module" src="index.js"></script> | ||
| </body> | ||
| </html> |
23 changes: 23 additions & 0 deletions1-js/99-js-misc/09-weakref-finalizationregistry/weakref-dom.view/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| const startMessagesBtn = document.querySelector('.start-messages'); // (1) | ||
| const closeWindowBtn = document.querySelector('.window__button'); // (2) | ||
| const windowElementRef = new WeakRef(document.querySelector(".window__body")); // (3) | ||
| startMessagesBtn.addEventListener('click', () => { // (4) | ||
| startMessages(windowElementRef); | ||
| startMessagesBtn.disabled = true; | ||
| }); | ||
| closeWindowBtn.addEventListener('click', () => document.querySelector(".window__body").remove()); // (5) | ||
| const startMessages = (element) => { | ||
| const timerId = setInterval(() => { // (6) | ||
| if (element.deref()) { // (7) | ||
| const payload = document.createElement("p"); | ||
| payload.textContent = `Сообщение: Статус системы OK: ${new Date().toLocaleTimeString()}`; | ||
| element.deref().append(payload); | ||
| } else { // (8) | ||
| alert("Элемент был удалён."); // (9) | ||
| clearInterval(timerId); | ||
| } | ||
| }, 1000); | ||
| }; |
32 changes: 32 additions & 0 deletions.../99-js-misc/09-weakref-finalizationregistry/weakref-finalizationregistry-01.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions.../99-js-misc/09-weakref-finalizationregistry/weakref-finalizationregistry-02.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.