Changeset 17610 in webkit


Ignore:
Timestamp:
Nov 6, 2006 12:30:01 AM (17 years ago)
Author:
bdash
Message:

2006-11-06 Mark Rowe <bdash@webkit.org>

Reviewed by the wonderful Mitz Pettel.

http://bugs.webkit.org/show_bug.cgi?id=11524
Bug 11524: REGRESSION(r9842): Array.prototype.join should use ToString operator rather than calling toString on each element

  • kjs/array_object.cpp: (ArrayProtoFunc::callAsFunction): Use ToString operator on each element rather than calling their toString method.

2006-11-06 Mark Rowe <bdash@webkit.org>

Reviewed by the wonderful Mitz Pettel.

Test for http://bugs.webkit.org/show_bug.cgi?id=11524
Bug 11524: REGRESSION(r9842): Array.prototype.join should use ToString operator rather than calling toString on each element

  • fast/js/array-join-bug-11524-expected.txt: Added.
  • fast/js/array-join-bug-11524.html: Added.
  • fast/js/resources/array-join-bug-11524.js: Added.
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r17587 r17610  
     12006-11-06  Mark Rowe  <bdash@webkit.org>
     2
     3        Reviewed by the wonderful Mitz Pettel.
     4
     5        http://bugs.webkit.org/show_bug.cgi?id=11524
     6        Bug 11524: REGRESSION(r9842): Array.prototype.join should use ToString operator rather than calling toString on each element
     7
     8        * kjs/array_object.cpp:
     9        (ArrayProtoFunc::callAsFunction): Use ToString operator on each element rather than calling their toString method.
     10
    1112006-11-03  Steve Falkenburg  <sfalken@apple.com>
    212
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r17372 r17610  
    470470    static HashSet<JSObject*> visitedElems;
    471471    if (visitedElems.contains(thisObj))
    472       return jsString("");
     472        return jsString("");
    473473    UString separator = ",";
    474474    UString str = "";
     
    476476    visitedElems.add(thisObj);
    477477    if (id == Join && !args[0]->isUndefined())
    478       separator = args[0]->toString(exec);
     478        separator = args[0]->toString(exec);
    479479    for (unsigned int k = 0; k < length; k++) {
    480       if (k >= 1)
    481         str += separator;
    482      
    483       JSValue *element = thisObj->get(exec, k);
    484       if (element->isUndefinedOrNull())
    485         continue;
    486 
    487       bool fallback = false;
    488       if (id == ToLocaleString) {
    489         JSObject *o = element->toObject(exec);
    490         JSValue *conversionFunction = o->get(exec, toLocaleStringPropertyName);
    491         if (conversionFunction->isObject() && static_cast<JSObject *>(conversionFunction)->implementsCall()) {
    492           str += static_cast<JSObject *>(conversionFunction)->call(exec, o, List())->toString(exec);
    493         } else {
    494           // try toString() fallback
    495           fallback = true;
     480        if (k >= 1)
     481            str += separator;
     482
     483        JSValue* element = thisObj->get(exec, k);
     484        if (element->isUndefinedOrNull())
     485            continue;
     486
     487        bool fallback = false;
     488        if (id == ToLocaleString) {
     489            JSObject* o = element->toObject(exec);
     490            JSValue* conversionFunction = o->get(exec, toLocaleStringPropertyName);
     491            if (conversionFunction->isObject() && static_cast<JSObject*>(conversionFunction)->implementsCall())
     492                str += static_cast<JSObject*>(conversionFunction)->call(exec, o, List())->toString(exec);
     493            else
     494                // try toString() fallback
     495                fallback = true;
    496496        }
    497       }
    498 
    499       if (id == ToString || id == Join || fallback) {
    500         if (element->isObject()) {
    501           JSObject *o = static_cast<JSObject *>(element);
    502           JSValue *conversionFunction = o->get(exec, toStringPropertyName);
    503           if (conversionFunction->isObject() && static_cast<JSObject *>(conversionFunction)->implementsCall()) {
    504             str += static_cast<JSObject *>(conversionFunction)->call(exec, o, List())->toString(exec);
    505           } else {
    506             visitedElems.remove(thisObj);
    507             return throwError(exec, RangeError, "Can't convert " + o->className() + " object to string");
    508           }
    509         } else {
    510           str += element->toString(exec);
    511         }
    512       }
    513 
    514       if ( exec->hadException() )
    515         break;
     497
     498        if (id == ToString || id == Join || fallback)
     499            str += element->toString(exec);
     500
     501        if (exec->hadException())
     502            break;
    516503    }
    517504    visitedElems.remove(thisObj);
  • trunk/LayoutTests/ChangeLog

    r17591 r17610  
     12006-11-06  Mark Rowe  <bdash@webkit.org>
     2
     3        Reviewed by the wonderful Mitz Pettel.
     4
     5        Test for http://bugs.webkit.org/show_bug.cgi?id=11524
     6        Bug 11524: REGRESSION(r9842): Array.prototype.join should use ToString operator rather than calling toString on each element
     7
     8        * fast/js/array-join-bug-11524-expected.txt: Added.
     9        * fast/js/array-join-bug-11524.html: Added.
     10        * fast/js/resources/array-join-bug-11524.js: Added.
     11
    1122006-11-04  Alexey Proskuryakov  <ap@nypop.com>
    213
Note: See TracChangeset for help on using the changeset viewer.