Changeset 207235 in webkit
- Timestamp:
- Oct 12, 2016 12:40:51 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChakraCore/test/Array/array_sort.baseline-jsc
r205387 r207235 8 8 10 9 9 1,1.2,4,4.8,12 10 TypeError: Array.prototype.sort requires the comparsion function be a function or undefined 10 11 1,2,3 -
trunk/JSTests/ChangeLog
r207226 r207235 1 2016-10-12 Keith Miller <keith_miller@apple.com> 2 3 Handle non-function, non-undefined comparator in Array.prototype.sort 4 https://bugs.webkit.org/show_bug.cgi?id=163085 5 6 Reviewed by Yusuke Suzuki. 7 8 * ChakraCore/test/Array/array_sort.baseline-jsc: 9 * stress/array-sort-bad-comparator.js: Added. 10 (test): 11 1 12 2016-10-12 Mark Lam <mark.lam@apple.com> 2 13 -
trunk/Source/JavaScriptCore/ChangeLog
r207230 r207235 1 2016-10-12 Keith Miller <keith_miller@apple.com> 2 3 Handle non-function, non-undefined comparator in Array.prototype.sort 4 https://bugs.webkit.org/show_bug.cgi?id=163085 5 6 Reviewed by Yusuke Suzuki. 7 8 * builtins/ArrayPrototype.js: 9 (sort.comparatorSort): 10 (sort.stringSort): 11 (sort): 12 1 13 2016-10-12 Filip Pizlo <fpizlo@apple.com> 2 14 -
trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js
r206853 r207235 607 607 } 608 608 609 function comparatorSort(array, comparator) 610 { 611 var length = array.length >>> 0; 612 613 // For compatibility with Firefox and Chrome, do nothing observable 614 // to the target array if it has 0 or 1 sortable properties. 615 if (length < 2) 616 return; 617 609 function comparatorSort(array, length, comparator) 610 { 618 611 var valueCount = compact(array, length); 619 612 mergeSort(array, valueCount, comparator); 620 613 } 621 614 622 function stringSort(array) 623 { 624 var length = array.length >>> 0; 625 626 // For compatibility with Firefox and Chrome, do nothing observable 627 // to the target array if it has 0 or 1 sortable properties. 628 if (length < 2) 629 return; 630 615 function stringSort(array, length) 616 { 631 617 var valueCount = compact(array, length); 632 618 … … 641 627 @throwTypeError("Array.prototype.sort requires that |this| not be null or undefined"); 642 628 643 if (typeof this == "string") 644 @throwTypeError("Attempted to assign to readonly property."); 645 646 var array = @Object(this); 629 var array = @Object(this); 630 631 var length = array.length >>> 0; 632 633 // For compatibility with Firefox and Chrome, do nothing observable 634 // to the target array if it has 0 or 1 sortable properties. 635 if (length < 2) 636 return array; 647 637 648 638 if (typeof comparator == "function") 649 comparatorSort(array, comparator); 639 comparatorSort(array, length, comparator); 640 else if (comparator === @undefined) 641 stringSort(array, length); 650 642 else 651 stringSort(array);643 @throwTypeError("Array.prototype.sort requires the comparsion function be a function or undefined"); 652 644 653 645 return array;
Note: See TracChangeset
for help on using the changeset viewer.