Skip to content
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

Cleaner attributeFilter/attributeOldValue example (MutationObserver) #32656

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mrienstra
Copy link
Contributor

Description

Simplify callback, in the MutationObserver example illustrating the usage of attributeFilter & attributeOldValue.

Motivation

I thought the old version had a typo, in userStatusChanged(mutation.target.username, mutation.target.status);, mutation.target.username seems like it should've been mutation.oldValue, though after taking a closer look, this was probably intentional.

While fixing this "typo", I decided the old callback was unnecessary complex -- e.g. the outer switch wasn't doing anything (aside from serving as a future placeholder perhaps) -- so I made it a bit more "to the point". Also seems a tiny bit unusual to have an example that calls functions not provided (userStatusChanged & usernameChanged), this new one is a little easier to modify and begin playing with.

Related issues and pull requests

Old version added in #9737:
https://github.com/mdn/content/pull/9737/files#diff-fc20b9f4adbc6723e9fe01425cea6512399d9a9bd69451d25f8fd6f0b8f92788R144-R170

Simplify example callback.

Old version had a typo, ` userStatusChanged(mutation.target.username, mutation.target.status);` ➝ ` userStatusChanged(mutation.oldValue, mutation.target.status);`

Old version added in mdn#9737:
https://github.com/mdn/content/pull/9737/files#diff-fc20b9f4adbc6723e9fe01425cea6512399d9a9bd69451d25f8fd6f0b8f92788R144-R170
@mrienstra mrienstra requested a review from a team as a code owner March 12, 2024 05:46
@mrienstra mrienstra requested review from Elchi3 and removed request for a team March 12, 2024 05:46
@github-actions github-actions bot added Content:WebAPI Web API docs size/s 6-50 LoC changed labels Mar 12, 2024
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs size/s 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant