diff --git a/core/modules/widgets/widget.js b/core/modules/widgets/widget.js index 53c5ea46b..679433071 100755 --- a/core/modules/widgets/widget.js +++ b/core/modules/widgets/widget.js @@ -195,16 +195,23 @@ Widget.prototype.hasVariable = function(name,value) { Construct a qualifying string based on a hash of concatenating the values of a given variable in the parent chain */ Widget.prototype.getStateQualifier = function(name) { + this.qualifiers = this.qualifiers || Object.create(null); name = name || "transclusion"; - var output = [], - node = this; - while(node && node.parentWidget) { - if($tw.utils.hop(node.parentWidget.variables,name)) { - output.push(node.getVariable(name)); + if(this.qualifiers[name]) { + return this.qualifiers[name]; + } else { + var output = [], + node = this; + while(node && node.parentWidget) { + if($tw.utils.hop(node.parentWidget.variables,name)) { + output.push(node.getVariable(name)); + } + node = node.parentWidget; } - node = node.parentWidget; + var value = $tw.utils.hashString(output.join("")); + this.qualifiers[name] = value; + return value; } - return $tw.utils.hashString(output.join("")); }; /*