GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: define Event.isTrusted in the prototype · nodejs/node@a738164

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • event_target.js
  • test
    • parallel
      • test-abortcontroller.js
      • test-events-customevent.js
      • test-eventtarget.js
    • wpt/status/dom
      • events.json
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/event_target.js‎

Copy file name to clipboardExpand all lines: lib/internal/event_target.js
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ class Event {
119119
isTrustedSet.add(this);
120120
}
121121

122-
// isTrusted is special (LegacyUnforgeable)
123-
ObjectDefineProperty(this, 'isTrusted', isTrustedDescriptor);
124122
this[kTarget] = null;
125123
this[kIsBeingDispatched] = false;
126124
}
@@ -343,6 +341,11 @@ ObjectDefineProperties(
343341
eventPhase: kEnumerableProperty,
344342
cancelBubble: kEnumerableProperty,
345343
stopPropagation: kEnumerableProperty,
344+
// Don't conform to the spec with isTrusted. The spec defines it as
345+
// LegacyUnforgeable but defining it in the constructor has a big
346+
// performance impact and the property doesn't seem to be useful outside of
347+
// browsers.
348+
isTrusted: isTrustedDescriptor,
346349
});
347350

348351
function isCustomEvent(value) {
Collapse file

‎test/parallel/test-abortcontroller.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-abortcontroller.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ const { setTimeout: sleep } = require('timers/promises');
5757
}));
5858
first.abort();
5959
second.abort();
60-
const firstTrusted = Reflect.getOwnPropertyDescriptor(ev1, 'isTrusted').get;
61-
const secondTrusted = Reflect.getOwnPropertyDescriptor(ev2, 'isTrusted').get;
62-
const untrusted = Reflect.getOwnPropertyDescriptor(ev3, 'isTrusted').get;
60+
const firstTrusted = Reflect.getOwnPropertyDescriptor(Object.getPrototypeOf(ev1), 'isTrusted').get;
61+
const secondTrusted = Reflect.getOwnPropertyDescriptor(Object.getPrototypeOf(ev2), 'isTrusted').get;
62+
const untrusted = Reflect.getOwnPropertyDescriptor(Object.getPrototypeOf(ev3), 'isTrusted').get;
6363
strictEqual(firstTrusted, secondTrusted);
6464
strictEqual(untrusted, firstTrusted);
6565
}
Collapse file

‎test/parallel/test-events-customevent.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-events-customevent.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ const { Event, EventTarget, CustomEvent } = require('internal/event_target');
187187
}
188188
{
189189
const ev = new CustomEvent('foo');
190-
deepStrictEqual(Object.keys(ev), ['isTrusted']);
190+
strictEqual(ev.isTrusted, false);
191191
}
192192

193193
// Works with EventTarget
Collapse file

‎test/parallel/test-eventtarget.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eventtarget.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ let asyncTest = Promise.resolve();
126126
}
127127
{
128128
const ev = new Event('foo');
129-
deepStrictEqual(Object.keys(ev), ['isTrusted']);
129+
strictEqual(ev.isTrusted, false);
130130
}
131131
{
132132
const eventTarget = new EventTarget();
Collapse file

‎test/wpt/status/dom/events.json‎

Copy file name to clipboardExpand all lines: test/wpt/status/dom/events.json
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
"Event-dispatch-listener-order.window.js": {
1212
"skip": "document is not defined"
1313
},
14+
"Event-isTrusted.any.js": {
15+
"fail": {
16+
"expected": [
17+
"Event-isTrusted"
18+
]
19+
}
20+
},
1421
"EventListener-addEventListener.sub.window.js": {
1522
"skip": "document is not defined"
1623
},

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.