Optimize style attributes overriding

This commit is contained in:
Philippe Proulx 2013-10-26 04:49:37 -04:00
parent 51916ebba3
commit 439734a49b
2 changed files with 19 additions and 9 deletions

View file

@ -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);

View file

@ -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),