Skip to content

Commit

Permalink
Fix the button does not retain its position when it's placed before a…
Browse files Browse the repository at this point in the history
… 'spring', 'spacer' or 'separator' (#3750)
  • Loading branch information
JustOff authored and gorhill committed Mar 4, 2019
1 parent e46e469 commit 9cc2950
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions platform/firefox/vapi-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2768,8 +2768,15 @@ vAPI.toolbarButton = {
}
// Found our button on this toolbar - but where on it?
var before = null;
for ( var i = index + 1; i < currentset.length; i++ ) {
before = toolbar.querySelector('[id="' + currentset[i] + '"]');
for ( var i = index + 1, special; i < currentset.length; i++ ) {
if ( (special = /^(spring|spacer|separator)$/.exec(currentset[i])) !== null ) {
// Special elements have pseudo-random ids different from specified in the currentset
var specials = toolbar.querySelectorAll('toolbar' + special[1]);
var remain = currentset.slice(i-currentset.length).filter(s => s == special[1]).length;
before = toolbar.querySelector('[id="' + specials[specials.length - remain].id + '"]');
} else {
before = toolbar.querySelector('[id="' + currentset[i] + '"]');
}
if ( before !== null ) {
break;
}
Expand Down

0 comments on commit 9cc2950

Please sign in to comment.