Skip to content

Commit 11bd86a

Browse files
Jake ChampionJakeChampion
authored andcommitted
Allow TextDecoder to be used as a base class to extend from within application javascript
1 parent 5f16d89 commit 11bd86a

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

c-dependencies/js-compute-runtime/js-compute-builtins.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5126,19 +5126,6 @@ namespace Slots {
51265126
enum { Count };
51275127
};
51285128

5129-
JSObject *create(JSContext *cx);
5130-
5131-
bool constructor(JSContext *cx, unsigned argc, Value *vp) {
5132-
CTOR_HEADER("TextDecoder", 0);
5133-
5134-
RootedObject self(cx, create(cx));
5135-
if (!self)
5136-
return false;
5137-
5138-
args.rval().setObject(*self);
5139-
return true;
5140-
}
5141-
51425129
const unsigned ctor_length = 0;
51435130

51445131
bool check_receiver(JSContext *cx, HandleValue receiver, const char *method_name);
@@ -5180,10 +5167,17 @@ bool encoding_get(JSContext *cx, unsigned argc, Value *vp) {
51805167
const JSFunctionSpec methods[] = {JS_FN("decode", decode, 1, JSPROP_ENUMERATE), JS_FS_END};
51815168

51825169
const JSPropertySpec properties[] = {JS_PSG("encoding", encoding_get, JSPROP_ENUMERATE), JS_PS_END};
5183-
5170+
bool constructor(JSContext *cx, unsigned argc, Value *vp);
51845171
CLASS_BOILERPLATE(TextDecoder)
51855172

5186-
JSObject *create(JSContext *cx) { return JS_NewObjectWithGivenProto(cx, &class_, proto_obj); }
5173+
bool constructor(JSContext *cx, unsigned argc, Value *vp) {
5174+
CTOR_HEADER("TextDecoder", 0);
5175+
5176+
RootedObject self(cx, JS_NewObjectForConstructor(cx, &class_, args));
5177+
5178+
args.rval().setObject(*self);
5179+
return true;
5180+
}
51875181
} // namespace TextDecoder
51885182

51895183
bool report_sequence_or_record_arg_error(JSContext *cx, const char *name, const char *alt_text) {

integration-tests/js-compute/fixtures/extend-from-builtins/extend-from-builtins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const builtins = [
99
// Headers,
1010
CacheOverride,
1111
// TextEncoder,
12-
// TextDecoder,
12+
TextDecoder,
1313
// URL,
1414
// URLSearchParams,
1515
]

0 commit comments

Comments
 (0)