Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/ui/filters.js

Issue 5398934247702528: Filter Preferences: Template conditions not evaluating to a boolean are interpreted as true (Closed)
Patch Set: Created March 12, 2014, 10:43 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/ui/filters.js
===================================================================
--- a/chrome/content/ui/filters.js
+++ b/chrome/content/ui/filters.js
@@ -131,17 +131,22 @@ var Templater =
{
if (node.localName == "if")
conditionals.push(node);
for (let i = 0; i < node.attributes.length; i++)
{
let attribute = node.attributes[i];
let len = attribute.value.length;
if (len >= 2 && attribute.value[0] == "{" && attribute.value[len - 1] == "}")
- attribute.value = Cu.evalInSandbox(attribute.value.substr(1, len - 2), sandbox);
+ {
+ let value = Cu.evalInSandbox(attribute.value.substr(1, len - 2), sandbox);
+ if (attribute.name == "condition")
+ value = value ? "true" : "false";
+ attribute.value = value;
+ }
}
}
// Process <if> tags - remove if condition is false, replace by their children
// if it is true
for each (let node in conditionals)
{
let fragment = document.createDocumentFragment();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld