期待通りに動かなくなっていた(regression)

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5567 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-12-20 19:03:22 +00:00
parent 259f5ae309
commit 1a81ebed90

View File

@ -88,7 +88,7 @@ var TreeStyleTabBookmarksService = {
return -1; return -1;
}, },
getTreeStructureFromItems : function(aIDs) getTreeStructureFromItems : function(aIDs, aDefaultParentID)
{ {
/* this returns... /* this returns...
[A] => -1 (parent is not in this tree) [A] => -1 (parent is not in this tree)
@ -98,10 +98,13 @@ var TreeStyleTabBookmarksService = {
[E] => -1 (parent is not in this tree, and this creates another tree) [E] => -1 (parent is not in this tree, and this creates another tree)
[F] => 0 (parent is 1st item in this another tree) [F] => 0 (parent is 1st item in this another tree)
*/ */
if (aDefaultParentID === void(0))
aDefaultParentID = -1;
var treeStructure = aIDs.map(function(aId, aIndex) { var treeStructure = aIDs.map(function(aId, aIndex) {
let id = this.getParentItem(aId); let id = this.getParentItem(aId);
let index = aIDs.indexOf(id); let index = aIDs.indexOf(id);
return index < aIndex ? index : -1 ; return index > aIndex ? aDefaultParent : index ;
}, this); }, this);
/* Correct patterns like: /* Correct patterns like:
@ -205,7 +208,7 @@ var TreeStyleTabBookmarksService = {
treeStructure.filter(function(aParent, aIndex) { return aParent == -1; }).length > 1 treeStructure.filter(function(aParent, aIndex) { return aParent == -1; }).length > 1
) { ) {
ids.unshift(-1); ids.unshift(-1);
treeStructure = TreeStyleTabBookmarksService.getTreeStructureFromItems(ids); treeStructure = TreeStyleTabBookmarksService.getTreeStructureFromItems(ids, 0);
urls.unshift(TreeStyleTabBookmarksService.getGroupTabURI(aFolderTitle)); urls.unshift(TreeStyleTabBookmarksService.getGroupTabURI(aFolderTitle));
} }
TreeStyleTabBookmarksService.readyToOpenNewTabGroup(null, treeStructure); TreeStyleTabBookmarksService.readyToOpenNewTabGroup(null, treeStructure);