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

DOM: Rename EventTarget#on() to EventTarget#when() #47237

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dom/observable/tentative/observable-constructor.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ promise_test(async t => {
// 1. A traditional event listener
// 2. An observable
event_target.addEventListener('customevent', e => parentResults.push(e));
const source = event_target.on('customevent');
const source = event_target.when('customevent');
source.subscribe(e => parentResults.push(e));

// Detach the iframe and fire an event at the event target. The parent will
Expand Down
16 changes: 8 additions & 8 deletions dom/observable/tentative/observable-event-target.any.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
test(() => {
const target = new EventTarget();
assert_implements(target.on, "The EventTarget interface has an `on` method");
assert_equals(typeof target.on, "function",
"EventTarget should have the on method");
assert_implements(target.when, "The EventTarget interface has an `when` method");
assert_equals(typeof target.when, "function",
"EventTarget should have the when method");

const testEvents = target.on("test");
const testEvents = target.when("test");
assert_true(testEvents instanceof Observable,
"EventTarget.on returns an Observable");
"EventTarget.when() returns an Observable");

const results = [];
testEvents.subscribe({
Expand All @@ -24,11 +24,11 @@ test(() => {

target.dispatchEvent(event);
assert_array_equals(results, [event, event]);
}, "EventTarget.on() returns an Observable");
}, "EventTarget.when() returns an Observable");

test(() => {
const target = new EventTarget();
const testEvents = target.on("test");
const testEvents = target.when("test");
const ac = new AbortController();
const results = [];
testEvents.subscribe({
Expand Down Expand Up @@ -58,7 +58,7 @@ test(() => {

test(() => {
const target = new EventTarget();
const testEvents = target.on("test");
const testEvents = target.when("test");
const results = [];
testEvents.subscribe(e => results.push(e));
testEvents.subscribe(e => results.push(e));
Expand Down
6 changes: 3 additions & 3 deletions dom/observable/tentative/observable-event-target.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ test(() => {
document.querySelector('body').appendChild(document.createElement('div'));

const body = document.querySelector('body');
const captureObservable = body.on('click', {capture: true});
const bubbleObservable = body.on('click', {capture: false});
const captureObservable = body.when('click', {capture: true});
const bubbleObservable = body.when('click', {capture: false});

const results = [];
captureObservable.subscribe(e => results.push(e.eventPhase));
Expand All @@ -24,7 +24,7 @@ test(() => {
test(() => {
const target = new EventTarget();

const observable = target.on('event', {passive: true});
const observable = target.when('event', {passive: true});
observable.subscribe(event => {
assert_false(event.defaultPrevented);
// Should do nothing, since `observable` is "passive".
Expand Down
2 changes: 1 addition & 1 deletion dom/observable/tentative/observable-from.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test(() => {

test(() => {
const target = new EventTarget();
const observable = target.on('custom');
const observable = target.when('custom');
const from_observable = Observable.from(observable);
assert_equals(observable, from_observable);
}, "from(): Given an observable, it returns that exact observable");
Expand Down
2 changes: 1 addition & 1 deletion dom/observable/tentative/observable-inspect.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ test(() => {

const controller = new AbortController();

self.on('error').take(1).subscribe(e =>
self.when('error').take(1).subscribe(e =>
results.push(e.message + ', from report exception'));

result.subscribe({
Expand Down