Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4c69be4

Browse filesBrowse files
KhafraDevdanielleadams
authored andcommitted
buffer: use private properties for brand checks in File
PR-URL: #47154 Refs: #46904 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 0c80e60 commit 4c69be4
Copy full SHA for 4c69be4

File tree

Expand file treeCollapse file tree

2 files changed

+11
-15
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-15
lines changed
Open diff view settings
Collapse file

‎lib/internal/file.js‎

Copy file name to clipboardExpand all lines: lib/internal/file.js
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const {
2121

2222
const {
2323
codes: {
24-
ERR_INVALID_THIS,
2524
ERR_MISSING_ARGS,
2625
},
2726
} = require('internal/errors');
@@ -64,18 +63,10 @@ class File extends Blob {
6463
}
6564

6665
get name() {
67-
if (!this || !(#name in this)) {
68-
throw new ERR_INVALID_THIS('File');
69-
}
70-
7166
return this.#name;
7267
}
7368

7469
get lastModified() {
75-
if (!this || !(#name in this)) {
76-
throw new ERR_INVALID_THIS('File');
77-
}
78-
7970
return this.#lastModified;
8071
}
8172

Collapse file

‎test/parallel/test-file.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-file.js
+11-6Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,15 @@ const { inspect } = require('util');
146146

147147
{
148148
const getter = Object.getOwnPropertyDescriptor(File.prototype, 'name').get;
149-
assert.throws(
150-
() => getter.call(undefined), // eslint-disable-line no-useless-call
151-
{
152-
code: 'ERR_INVALID_THIS',
153-
}
154-
);
149+
150+
[
151+
undefined,
152+
null,
153+
true,
154+
].forEach((invalidThis) => {
155+
assert.throws(
156+
() => getter.call(invalidThis),
157+
TypeError
158+
);
159+
});
155160
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.