Optimize style attributes overriding
This commit is contained in:
parent
51916ebba3
commit
439734a49b
2 changed files with 19 additions and 9 deletions
|
@ -88,16 +88,7 @@ models.service('models', ['$rootScope', function($rootScope) {
|
|||
if (textEl.attrs.name !== null) {
|
||||
textEl.classes.push('coa-' + textEl.attrs.name);
|
||||
}
|
||||
var allReset = true;
|
||||
for (var attr in textEl.attrs.override) {
|
||||
if (textEl.attrs.override[attr]) {
|
||||
allReset = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allReset) {
|
||||
textEl.classes.push('a-reset');
|
||||
} else for (var attr in textEl.attrs.override) {
|
||||
val = textEl.attrs.override[attr];
|
||||
if (val) {
|
||||
textEl.classes.push('a-' + attr);
|
||||
|
|
|
@ -461,6 +461,7 @@
|
|||
var curBgColor = WeeChatProtocol._getDefaultColor();
|
||||
var curAttrs = WeeChatProtocol._getDefaultAttributes();
|
||||
var curSpecialToken = null;
|
||||
var curAttrsOnlyFalseOverrides = true;
|
||||
|
||||
return parts.map(function(p) {
|
||||
if (p.length == 0) {
|
||||
|
@ -529,6 +530,24 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
/* As long as attributes are only false overrides, without any option
|
||||
* name, it's safe to remove them.
|
||||
*/
|
||||
if (curAttrsOnlyFalseOverrides && curAttrs.name === null) {
|
||||
var allReset = true;
|
||||
for (var attr in curAttrs.override) {
|
||||
if (curAttrs.override[attr]) {
|
||||
allReset = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allReset) {
|
||||
curAttrs.override = {};
|
||||
} else {
|
||||
curAttrsOnlyFalseOverrides = false;
|
||||
}
|
||||
}
|
||||
|
||||
// parsed text element
|
||||
return {
|
||||
fgColor: WeeChatProtocol._cloneColor(curFgColor),
|
||||
|
|
Loading…
Reference in a new issue