Ignore:
Timestamp:
Jan 14, 2008, 1:12:18 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by David Kilzer.

http://bugs.webkit.org/show_bug.cgi?id=16787
array.splice() with 1 element not working

Test: fast/js/array-splice.html

  • kjs/array_object.cpp: (KJS::ArrayProtoFuncSplice::callAsFunction): Implement this Mozilla extension, and fix some other edge cases.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r29067 r29459  
    431431    JSValue* result = resObj;
    432432    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     433    if (!args.size())
     434        return jsUndefined();
    433435    int begin = args[0]->toUInt32(exec);
    434436    if (begin < 0)
     
    436438    else
    437439        begin = std::min<int>(begin, length);
    438     unsigned int deleteCount = std::min<int>(std::max<int>(args[1]->toUInt32(exec), 0), length - begin);
     440
     441    unsigned int deleteCount;
     442    if (args.size() > 1)
     443        deleteCount = std::min<int>(std::max<int>(args[1]->toUInt32(exec), 0), length - begin);
     444    else
     445        deleteCount = length - begin;
    439446
    440447    for (unsigned int k = 0; k < deleteCount; k++) {
Note: See TracChangeset for help on using the changeset viewer.