Skip to content

Commit

Permalink
Bug 1658308 - Backout Array.prototype.item and %TypedArray%.prototype…
Browse files Browse the repository at this point in the history
….item.

There are too many web compatibility issues. Keeping this on Nightly is not going
to be useful.

Differential Revision: https://phabricator.services.mozilla.com/D92987
  • Loading branch information
evilpie committed Oct 8, 2020
1 parent cad53f4 commit 436fcfb
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 172 deletions.
5 changes: 0 additions & 5 deletions js/src/builtin/Array.cpp
Expand Up @@ -3760,11 +3760,6 @@ static const JSFunctionSpec array_methods[] = {
JS_SELF_HOSTED_FN("flatMap", "ArrayFlatMap", 1, 0),
JS_SELF_HOSTED_FN("flat", "ArrayFlat", 0, 0),

/* Proposal */
#ifdef NIGHTLY_BUILD
JS_SELF_HOSTED_FN("item", "ArrayItem", 1, 0),
#endif

JS_FS_END};

static const JSFunctionSpec array_static_methods[] = {
Expand Down
29 changes: 0 additions & 29 deletions js/src/builtin/Array.js
Expand Up @@ -1140,32 +1140,3 @@ function FlattenIntoArray(target, source, sourceLen, start, depth, mapperFunctio
// Step 4.
return targetIndex;
}

// https://github.com/tc39/proposal-item-method
// Array.prototype.item ( index )
function ArrayItem(index) {
// Step 1.
var O = ToObject(this);

// Step 2.
var len = ToLength(O.length);

// Step 3.
var relativeIndex = ToInteger(index);

// Steps 4-5.
var k;
if (relativeIndex >= 0) {
k = relativeIndex;
} else {
k = len + relativeIndex;
}

// Step 6.
if (k < 0 || k >= len) {
return undefined;
}

// Step 7.
return O[k];
}
39 changes: 0 additions & 39 deletions js/src/builtin/TypedArray.js
Expand Up @@ -1335,45 +1335,6 @@ function TypedArraySubarray(begin, end) {
return TypedArraySpeciesCreateWithBuffer(obj, buffer, beginByteOffset, newLength);
}

// https://github.com/tc39/proposal-item-method
// %TypedArray%.prototype.item ( index )
function TypedArrayItem(index) {
// Step 1.
var obj = this;

// Step 2.
// This function is not generic.
if (!IsObject(obj) || !IsTypedArray(obj)) {
return callFunction(CallTypedArrayMethodIfWrapped, obj, index,
"TypedArrayItem");
}
GetAttachedArrayBuffer(obj);

// If we got here, `this` is either a typed array or a wrapper for one.

// Step 3.
var len = TypedArrayLength(obj);

// Step 4.
var relativeIndex = ToInteger(index);

// Steps 5-6.
var k;
if (relativeIndex >= 0) {
k = relativeIndex;
} else {
k = len + relativeIndex;
}

// Step 7.
if (k < 0 || k >= len) {
return undefined;
}

// Step 8.
return obj[k];
}

// ES6 draft rev30 (2014/12/24) 22.2.3.30 %TypedArray%.prototype.values()
//
// Uncloned functions with `$` prefix are allocated as extended function
Expand Down
41 changes: 0 additions & 41 deletions js/src/tests/non262/Array/item.js

This file was deleted.

49 changes: 0 additions & 49 deletions js/src/tests/non262/TypedArray/item.js

This file was deleted.

3 changes: 0 additions & 3 deletions js/src/vm/TypedArrayObject.cpp
Expand Up @@ -1919,9 +1919,6 @@ bool TypedArrayObject::set(JSContext* cx, unsigned argc, Value* vp) {
JS_SELF_HOSTED_FN("includes", "TypedArrayIncludes", 2, 0),
JS_SELF_HOSTED_FN("toString", "ArrayToString", 0, 0),
JS_SELF_HOSTED_FN("toLocaleString", "TypedArrayToLocaleString", 2, 0),
#ifdef NIGHTLY_BUILD
JS_SELF_HOSTED_FN("item", "TypedArrayItem", 1, 0),
#endif
JS_FS_END};

/* static */ const JSFunctionSpec TypedArrayObject::staticFunctions[] = {
Expand Down
6 changes: 0 additions & 6 deletions js/xpconnect/tests/chrome/test_xrayToJS.xhtml
Expand Up @@ -235,9 +235,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
"includes", "forEach", "map", "reduce", "reduceRight", "filter", "some", "every", "find",
"findIndex", "copyWithin", "fill", Symbol.iterator, Symbol.unscopables, "entries", "keys",
"values", "constructor", "flat", "flatMap"];
if (isNightlyBuild) {
gPrototypeProperties['Array'].push("item");
}
gConstructorProperties['Array'] =
constructorProps(["isArray", "from", "of", Symbol.species]);
for (var c of typedArrayClasses) {
Expand All @@ -249,9 +246,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
"set", "copyWithin", "find", "findIndex", "forEach","indexOf", "lastIndexOf", "includes",
"reverse", "join", "every", "some", "reduce", "reduceRight", "entries", "keys", "values",
"slice", "map", "filter"];
if (isNightlyBuild) {
gPrototypeProperties['TypedArray'].push("item");
}
// There is no TypedArray constructor, looks like.
is(window.TypedArray, undefined, "If this ever changes, add to this test!");
for (var c of errorObjectClasses) {
Expand Down

0 comments on commit 436fcfb

Please sign in to comment.