-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Typos #2095
Conversation
There was a problem hiding this comment.
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. :-)
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
commented
Sep 5, 2020
Thank you 🚀 !
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); }
MuhammedZakir
commented
Sep 17, 2020
@iliakan ?
iliakan
commented
Sep 17, 2020
@MuhammedZakir I updated the article.
No description provided.