Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Typos #2095

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

Merged
iliakan merged 10 commits into javascript-tutorial:master from peachesontour:patch-11
Sep 5, 2020
Merged

Typos #2095

iliakan merged 10 commits into javascript-tutorial:master from peachesontour:patch-11
Sep 5, 2020

Conversation

@peachesontour
Copy link
Contributor

@peachesontour peachesontour commented Aug 30, 2020

No description provided.

Copy link
Contributor

@MuhammedZakir MuhammedZakir left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code snippet about observer.takeRecords() is wrong. [1] Please change it to

// save the list of unprocessed mutations to a variable
let mutationRecords = observer.takeRecords();
// stop tracking changes
observer.disconnect();
// if there is any unprocessed mutation record
if (mutationRecords.length) {
 // handle our unprocessed mutations here
 ...
}

[1] Lines 245-252 - https://github.com/javascript-tutorial/en.javascript.info/pull/2095/files#diff-07efa9eed0cbe0def12cac161a14ae34R245-R252

Edit: In case you don't know, all the other changes except this one can be easily added - https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request. :-)

peachesontour and others added 9 commits September 1, 2020 08:53
Co-authored-by: Muhammed Zakir <8190126+MuhammedZakir@users.noreply.github.com>
Co-authored-by: Muhammed Zakir <8190126+MuhammedZakir@users.noreply.github.com>
Co-authored-by: Muhammed Zakir <8190126+MuhammedZakir@users.noreply.github.com>
Co-authored-by: Muhammed Zakir <8190126+MuhammedZakir@users.noreply.github.com>
Co-authored-by: Muhammed Zakir <8190126+MuhammedZakir@users.noreply.github.com>
Co-authored-by: Muhammed Zakir <8190126+MuhammedZakir@users.noreply.github.com>
Co-authored-by: Muhammed Zakir <8190126+MuhammedZakir@users.noreply.github.com>
Co-authored-by: Muhammed Zakir <8190126+MuhammedZakir@users.noreply.github.com>
Co-authored-by: Muhammed Zakir <8190126+MuhammedZakir@users.noreply.github.com>
@iliakan iliakan merged commit 30386fc into javascript-tutorial:master Sep 5, 2020
Copy link
Member

iliakan commented Sep 5, 2020

Thank you 🚀 !

Copy link
Contributor

MuhammedZakir commented Sep 11, 2020
edited
Loading

Code snippet about observer.takeRecords() is wrong. [1] Please change it to

// save the list of unprocessed mutations to a variable
let mutationRecords = observer.takeRecords();
// stop tracking changes
observer.disconnect();
// if there is any unprocessed mutation record
if (mutationRecords.length) {
 // handle our unprocessed mutations here
 ...
}

[1] Lines 245-252 - https://github.com/javascript-tutorial/en.javascript.info/pull/2095/files#diff-07efa9eed0cbe0def12cac161a14ae34R245-R252

Edit: In case you don't know, all the other changes except this one can be easily added - https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request. :-)

Am I wrong? I could not get a list of mutation records when calling takeRecords() after disconnecting.

const cb = (mutationRecords) => {
 console.log(`${mutationRecords.length} change(s) detected.`);
};
const p = document.querySelector("p");
const observer = new MutationObserver(cb);
observer.observe(p, {
 childList: true
});
p.innerText = "Text changed.";
observer.disconnect();
const mutationRecords = observer.takeRecords(); // calling after disconnecting does not work
if (mutationRecords.length) {
 console.log("manual call");
 cb(mutationRecords);
}

This works -

const cb = (mutationRecords) => {
 console.log(`${mutationRecords.length} change(s) detected`);
};
const p = document.querySelector("p");
const observer = new MutationObserver(cb);
observer.observe(p, {
 childList: true
});
p.innerText = "Text changed."
const mutationRecords = observer.takeRecords(); // calling before disconnecting. This works!
observer.disconnect();
if (mutationRecords.length) {
 console.log("manual call");
 cb(mutationRecords);
}

Copy link
Contributor

Copy link
Member

iliakan commented Sep 17, 2020

@MuhammedZakir I updated the article.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@MuhammedZakir MuhammedZakir MuhammedZakir requested changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /