| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 let nodeIterator = document.createNodeIterator(result, NodeFilter.SHOW_ELEME
NT, null, false); | 129 let nodeIterator = document.createNodeIterator(result, NodeFilter.SHOW_ELEME
NT, null, false); |
| 130 for (let node = nodeIterator.nextNode(); node; node = nodeIterator.nextNode(
)) | 130 for (let node = nodeIterator.nextNode(); node; node = nodeIterator.nextNode(
)) |
| 131 { | 131 { |
| 132 if (node.localName == "if") | 132 if (node.localName == "if") |
| 133 conditionals.push(node); | 133 conditionals.push(node); |
| 134 for (let i = 0; i < node.attributes.length; i++) | 134 for (let i = 0; i < node.attributes.length; i++) |
| 135 { | 135 { |
| 136 let attribute = node.attributes[i]; | 136 let attribute = node.attributes[i]; |
| 137 let len = attribute.value.length; | 137 let len = attribute.value.length; |
| 138 if (len >= 2 && attribute.value[0] == "{" && attribute.value[len - 1] ==
"}") | 138 if (len >= 2 && attribute.value[0] == "{" && attribute.value[len - 1] ==
"}") |
| 139 attribute.value = Cu.evalInSandbox(attribute.value.substr(1, len - 2),
sandbox); | 139 { |
| 140 let value = Cu.evalInSandbox(attribute.value.substr(1, len - 2), sandb
ox); |
| 141 if (attribute.name == "condition") |
| 142 value = value ? "true" : "false"; |
| 143 attribute.value = value; |
| 144 } |
| 140 } | 145 } |
| 141 } | 146 } |
| 142 | 147 |
| 143 // Process <if> tags - remove if condition is false, replace by their childr
en | 148 // Process <if> tags - remove if condition is false, replace by their childr
en |
| 144 // if it is true | 149 // if it is true |
| 145 for each (let node in conditionals) | 150 for each (let node in conditionals) |
| 146 { | 151 { |
| 147 let fragment = document.createDocumentFragment(); | 152 let fragment = document.createDocumentFragment(); |
| 148 let condition = node.getAttribute("condition"); | 153 let condition = node.getAttribute("condition"); |
| 149 if (condition == "false") | 154 if (condition == "false") |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 * data object. | 217 * data object. |
| 213 */ | 218 */ |
| 214 getNodeForData: function(/**Node*/ parent, /**String*/ property, /**Object*/ d
ata) /**Node*/ | 219 getNodeForData: function(/**Node*/ parent, /**String*/ property, /**Object*/ d
ata) /**Node*/ |
| 215 { | 220 { |
| 216 for (let child = parent.firstChild; child; child = child.nextSibling) | 221 for (let child = parent.firstChild; child; child = child.nextSibling) |
| 217 if ("_data" in child && property in child._data && child._data[property] =
= data) | 222 if ("_data" in child && property in child._data && child._data[property] =
= data) |
| 218 return child; | 223 return child; |
| 219 return null; | 224 return null; |
| 220 } | 225 } |
| 221 }; | 226 }; |
| OLD | NEW |