関係ない属性が勝手にセットされていたのではなく、ルート要素の関係ない属性まで意図せず設定してしまっていた

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@7193 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2010-09-14 01:04:00 +00:00
parent 0e53ba4916
commit 2b9adcd464

View File

@ -763,12 +763,16 @@ var TreeStyleTabUtils = {
{
var strip = this.tabStrip;
if (!strip) return;
var isFeatureAttribute = aAttr.indexOf('treestyletab-') == 0;
if (aValue) {
strip.setAttribute(aAttr, aValue);
strip.ownerDocument.defaultView.setTimeout(function(aSelf) {
// setting an attribute to a root element sometimes breaks others...
aSelf.safeSetAttribute(strip.ownerDocument.documentElement, aAttr, aValue);
}, 10, this);
if (isFeatureAttribute) {
// Only attributes for TST's feature are applied to the root element.
// (width, height, and other general attributes have to be ignored!)
strip.ownerDocument.defaultView.setTimeout(function(aSelf) {
strip.ownerDocument.documentElement.setAttribute(aAttr, aValue);
}, 10, this);
}
if (this._tabStripPlaceHolder)
this._tabStripPlaceHolder.setAttribute(aAttr, aValue);
if (strip.tabsToolbarInnerBox)
@ -776,9 +780,11 @@ var TreeStyleTabUtils = {
}
else {
strip.removeAttribute(aAttr);
strip.ownerDocument.defaultView.setTimeout(function(aSelf) {
aSelf.safeSetAttribute(strip.ownerDocument.documentElement, aAttr);
}, 10, this);
if (isFeatureAttribute) {
strip.ownerDocument.defaultView.setTimeout(function(aSelf) {
strip.ownerDocument.documentElement.removeAttribute(aAttr);
}, 10, this);
}
if (this._tabStripPlaceHolder)
this._tabStripPlaceHolder.removeAttribute(aAttr);
if (strip.tabsToolbarInnerBox)
@ -791,44 +797,6 @@ var TreeStyleTabUtils = {
this.setTabStripAttribute(aAttr, null);
},
safeSetAttribute : function TSTUtils_safeSetAttribute(aElem, aAttr, aValue)
{
var expected = {};
Array.slice(aElem.attributes).forEach(function(aAttr) {
expected[aAttr.name] = aAttr.value;
});
if (aValue) {
expected[aAttr] = String(aValue);
aElem.setAttribute(aAttr, aValue);
}
else {
expected[aAttr] = '';
aElem.removeAttribute(aAttr);
}
for (let i in expected)
{
if (expected[i] != aElem.getAttribute(i)) {
dump('TSTUtils_safeSetAttribute restores '+aElem+'.'+i+
', from '+aElem.getAttribute(i)+' to '+expected[i]+'\n');
if (expected[i])
aElem.setAttribute(i, expected[i]);
else
aElem.removeAttribute(i);
}
}
// verification
for (let i in expected)
{
if (expected[i] != aElem.getAttribute(i)) {
dump(' => failed to change '+aElem+'.'+i+
', from '+aElem.getAttribute(i)+' to '+expected[i]+'\n');
}
}
},
getTabFromChild : function TSTUtils_getTabFromChild(aTab)
{
return this.evaluateXPath(