aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/controllers/styles-controller.js29
1 files changed, 24 insertions, 5 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 8fc90e7d..6ba24aa6 100644
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -736,7 +736,6 @@ var stylesController = exports.StylesController = Montage.create(Component, {
736 ///// Returns the specificity value of passed-in selector 736 ///// Returns the specificity value of passed-in selector
737 ///// WARNING: Do not pass in grouped selectors! 737 ///// WARNING: Do not pass in grouped selectors!
738 ///// Helpful for determining precedence of style rules 738 ///// Helpful for determining precedence of style rules
739 ///// Calculation javascript code courtesy of David Owens:
740 ///// http://gbradley.com/2009/10/02/css-specificity-in-javascript 739 ///// http://gbradley.com/2009/10/02/css-specificity-in-javascript
741 ///// Used with author's permission 740 ///// Used with author's permission
742 741
@@ -1177,15 +1176,24 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1177 1176
1178 _clearCache: { 1177 _clearCache: {
1179 value: function(element) { 1178 value: function(element) {
1180 var itemsToClear = this._cacheHistory; 1179 var itemsToNullify = this._cacheHistory,
1180 itemsToRemove = [],
1181 i;
1182
1181 1183
1184 ///// If clearing the cache for an element, filter by element
1185 ///// and keep track of indices to remove from cache
1182 if(element) { 1186 if(element) {
1183 itemsToClear = itemsToClear.filter(function(item) { 1187 itemsToNullify = itemsToNullify.filter(function(item, index) {
1184 return item.element === element; 1188 if(item.element === element) {
1189 itemsToRemove.push(index);
1190 return true;
1191 }
1192 return false;
1185 }); 1193 });
1186 } 1194 }
1187 1195
1188 itemsToClear.forEach(function(item) { 1196 itemsToNullify.forEach(function(item) {
1189 //var identifier = item.element.nodeName; 1197 //var identifier = item.element.nodeName;
1190 //identifier += '#'+item.element.id || '.'+item.element.className; 1198 //identifier += '#'+item.element.id || '.'+item.element.className;
1191 //console.log("clearing cache for \"" + item.property +"\" and element \"" + identifier+ ""); 1199 //console.log("clearing cache for \"" + item.property +"\" and element \"" + identifier+ "");
@@ -1194,6 +1202,17 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1194 } 1202 }
1195 }); 1203 });
1196 1204
1205 ///// Remove the nullified items from the cache
1206 ///// Start at the end to not mess up index references
1207 for(i = itemsToRemove.length-1; i >= 0; i--) {
1208 this._cacheHistory.splice(itemsToRemove[i], 1);
1209 }
1210
1211 if(!element) {
1212 this._cacheHistory = null;
1213 this._cacheHistory = [];
1214 }
1215
1197 } 1216 }
1198 }, 1217 },
1199 _removeCachedRuleForProperty : { 1218 _removeCachedRuleForProperty : {