-
Notifications
You must be signed in to change notification settings - Fork 22.4k
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
fix(CookieChangeEvent): revise misleading descriptions #33462
base: main
Are you sure you want to change the base?
Conversation
Preview URLs (comment last updated: 2024-05-14 13:30:27) |
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.
The original page doesn't make sense but this PR doesn't make sense either. It seems to me like we want to say something like:
The `CookieChangeEvent` interface of the {{domxref("Cookie Store API", "", "", "nocode")}}represents a change to the contents of the cookie store. An instance of a `CookieChangeEvent` is passed into the event handler for the {{domxref("CookieStore.change_event", "change")}} event of the `CookieStore` interface.
The `CookieChangeEvent` interface has two properties to represent cookie changes:
- `changed`: an array of objects representing cookies that have been newly created and not immediately evicted.
- `deleted`: an array of objects representing cookies which have been newly created and immediately evicted, or cookies which have been otherwise evicted or removed.
Note that the `change` event ignores cookies which were removed removed due to an insertion of another cookie with the same name, domain, and path.
After verification, I have question about "immediately evicted". See the follow test case: cookieStore.addEventListener("change", (event) => {
console.log(event)
});
// Test Case 1: set and delete immediately
// actually, log twice:
// firstly, log CookieChangeEvent { changed(1), deleted(0) }
// seccondly, log CookieChangeEvent { changed(0), deleted(1) }
cookieStore.set('cookie1', '123');
cookieStore.delete('cookie1');
// Test Case 2: set and delete immediately 2
// actually, log twice:
// firstly, log CookieChangeEvent { changed(1), deleted(0) }
// seccondly, log CookieChangeEvent { changed(0), deleted(1) }
const cookie3 = {
name: 'c2',
value: 'c2222',
}
cookieStore.set(cookie3 );
cookieStore.delete(cookie3);
// Test Case 3: set a expire cookie (passed)
// actually log once: CookieChangeEvent { changed(0), deleted(1) }
cookieStore.set({
name: 'c2',
value: 'c2222',
expires: Date.now() - 100,
}); How to define "immediately evicted" ? |
Wouldn't it be better to describe the details in the properties section? |
Co-authored-by: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com>
Thanks for raising this! I've asked for clarification in WICG/cookie-store#229. |
Yes, probably. You mean something like:
? |
Yes.
|
Based on WICG/cookie-store#229, I wonder if it would be better to remove the "immediately evicted" language from MDN, since that seems to be more targeted at people implementing the API, rather than people using it. something like:
? We could also keep an eye on WICG/cookie-store#229 and revise this again if it seems to be needed... Note that we do already say, in https://developer.mozilla.org/en-US/docs/Web/API/CookieStore/delete:
|
@xyy94813 , please let me know if you are coming back to this, if not I'm happy to try to finish it off. |
No. |
Description
cookie changes
.type
belongs tocookie changes
.Motivation
The previous description misinterpreted
type
as referring to the type attribute of the CookieChangeEvent.Additional details
https://wicg.github.io/cookie-store/#process-changes
Related issues and pull requests
Relates to mdn/translated-content#19845