зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1062490 - Array indexes in console.table() are sorted lexicographically. r=harth
This commit is contained in:
Родитель
9bc48158ab
Коммит
77141094b8
|
@ -593,7 +593,7 @@ Column.prototype = {
|
|||
* Selects the row at the `index` index
|
||||
*/
|
||||
selectRowAt: function(index) {
|
||||
if (this.selectedRow) {
|
||||
if (this.selectedRow != null) {
|
||||
this.cells[this.items[this.selectedRow]].toggleClass("theme-selected");
|
||||
}
|
||||
if (index < 0) {
|
||||
|
@ -930,7 +930,7 @@ Cell.prototype = {
|
|||
|
||||
set value(value) {
|
||||
this._value = value;
|
||||
if (!value) {
|
||||
if (value == null) {
|
||||
this.label.setAttribute("value", "");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1785,6 +1785,12 @@ Messages.ConsoleTable.prototype = Heritage.extend(Messages.Extended.prototype,
|
|||
this._columns["_index"] = l10n.getStr("table.index");
|
||||
}
|
||||
|
||||
if (data.class == "Array") {
|
||||
if (index == parseInt(index)) {
|
||||
index = parseInt(index);
|
||||
}
|
||||
}
|
||||
|
||||
let property = ownProperties[index].value;
|
||||
let item = { _index: index };
|
||||
|
||||
|
@ -1832,10 +1838,9 @@ Messages.ConsoleTable.prototype = Heritage.extend(Messages.Extended.prototype,
|
|||
}
|
||||
|
||||
let rowCount = 0;
|
||||
for (let index of Object.keys(entries || {})) {
|
||||
let [key, value] = entries[index];
|
||||
for (let [key, value] of entries) {
|
||||
let item = {
|
||||
_index: index,
|
||||
_index: rowCount,
|
||||
_key: this._renderValueGrip(key, { concise: true }),
|
||||
_value: this._renderValueGrip(value, { concise: true })
|
||||
};
|
||||
|
@ -1857,11 +1862,10 @@ Messages.ConsoleTable.prototype = Heritage.extend(Messages.Extended.prototype,
|
|||
}
|
||||
|
||||
let rowCount = 0;
|
||||
for (let index of Object.keys(entries || {})) {
|
||||
let value = entries[index];
|
||||
for (let entry of entries) {
|
||||
let item = {
|
||||
_index : index,
|
||||
_value: this._renderValueGrip(value, { concise: true })
|
||||
_index : rowCount,
|
||||
_value: this._renderValueGrip(entry, { concise: true })
|
||||
};
|
||||
|
||||
this._data.push(item);
|
||||
|
|
|
@ -12,27 +12,27 @@ const TEST_DATA = [
|
|||
{
|
||||
command: "console.table(languages1)",
|
||||
data: [
|
||||
{ _index: "0", name: "\"JavaScript\"", fileExtension: "Array[1]" },
|
||||
{ _index: "1", name: "Object", fileExtension: "\".ts\"" },
|
||||
{ _index: "2", name: "\"CoffeeScript\"", fileExtension: "\".coffee\"" }
|
||||
{ _index: 0, name: "\"JavaScript\"", fileExtension: "Array[1]" },
|
||||
{ _index: 1, name: "Object", fileExtension: "\".ts\"" },
|
||||
{ _index: 2, name: "\"CoffeeScript\"", fileExtension: "\".coffee\"" }
|
||||
],
|
||||
columns: { _index: "(index)", name: "name", fileExtension: "fileExtension" }
|
||||
},
|
||||
{
|
||||
command: "console.table(languages1, 'name')",
|
||||
data: [
|
||||
{ _index: "0", name: "\"JavaScript\"", fileExtension: "Array[1]" },
|
||||
{ _index: "1", name: "Object", fileExtension: "\".ts\"" },
|
||||
{ _index: "2", name: "\"CoffeeScript\"", fileExtension: "\".coffee\"" }
|
||||
{ _index: 0, name: "\"JavaScript\"", fileExtension: "Array[1]" },
|
||||
{ _index: 1, name: "Object", fileExtension: "\".ts\"" },
|
||||
{ _index: 2, name: "\"CoffeeScript\"", fileExtension: "\".coffee\"" }
|
||||
],
|
||||
columns: { _index: "(index)", name: "name" }
|
||||
},
|
||||
{
|
||||
command: "console.table(languages1, ['name'])",
|
||||
data: [
|
||||
{ _index: "0", name: "\"JavaScript\"", fileExtension: "Array[1]" },
|
||||
{ _index: "1", name: "Object", fileExtension: "\".ts\"" },
|
||||
{ _index: "2", name: "\"CoffeeScript\"", fileExtension: "\".coffee\"" }
|
||||
{ _index: 0, name: "\"JavaScript\"", fileExtension: "Array[1]" },
|
||||
{ _index: 1, name: "Object", fileExtension: "\".ts\"" },
|
||||
{ _index: 2, name: "\"CoffeeScript\"", fileExtension: "\".coffee\"" }
|
||||
],
|
||||
columns: { _index: "(index)", name: "name" }
|
||||
},
|
||||
|
@ -47,8 +47,8 @@ const TEST_DATA = [
|
|||
{
|
||||
command: "console.table([[1, 2], [3, 4]])",
|
||||
data: [
|
||||
{ _index: "0", 0: "1", 1: "2" },
|
||||
{ _index: "1", 0: "3", 1: "4" }
|
||||
{ _index: 0, 0: "1", 1: "2" },
|
||||
{ _index: 1, 0: "3", 1: "4" }
|
||||
],
|
||||
columns: { _index: "(index)", 0: "0", 1: "1" }
|
||||
},
|
||||
|
@ -93,19 +93,19 @@ const TEST_DATA = [
|
|||
{
|
||||
command: "console.table(mySet)",
|
||||
data: [
|
||||
{ _index: "0", _value: "1" },
|
||||
{ _index: "1", _value: "5" },
|
||||
{ _index: "2", _value: "\"some text\"" },
|
||||
{ _index: "3", _value: "null" },
|
||||
{ _index: "4", _value: "undefined" }
|
||||
{ _index: 0, _value: "1" },
|
||||
{ _index: 1, _value: "5" },
|
||||
{ _index: 2, _value: "\"some text\"" },
|
||||
{ _index: 3, _value: "null" },
|
||||
{ _index: 4, _value: "undefined" }
|
||||
],
|
||||
columns: { _index: "(iteration index)", _value: "Values" }
|
||||
},
|
||||
{
|
||||
command: "console.table(myMap)",
|
||||
data: [
|
||||
{ _index: "0", _key: "\"a string\"", _value: "\"value associated with 'a string'\"" },
|
||||
{ _index: "1", _key: "5", _value: "\"value associated with 5\"" },
|
||||
{ _index: 0, _key: "\"a string\"", _value: "\"value associated with 'a string'\"" },
|
||||
{ _index: 1, _key: "5", _value: "\"value associated with 5\"" },
|
||||
],
|
||||
columns: { _index: "(iteration index)", _key: "Key", _value: "Values" }
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче