OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 /** | 110 /** |
111 * Processes a template node using given data object. | 111 * Processes a template node using given data object. |
112 */ | 112 */ |
113 process: function(/**Node*/ template, /**Object*/ data) /**Node*/ | 113 process: function(/**Node*/ template, /**Object*/ data) /**Node*/ |
114 { | 114 { |
115 // Use a sandbox to resolve attributes (for convenience, not security) | 115 // Use a sandbox to resolve attributes (for convenience, not security) |
116 let sandbox = Cu.Sandbox(window); | 116 let sandbox = Cu.Sandbox(window); |
117 for (let key in data) | 117 for (let key in data) |
118 sandbox[key] = data[key]; | 118 sandbox[key] = data[key]; |
119 sandbox.formatTime = Utils.formatTime; | 119 sandbox.formatTime = Utils.formatTime; |
| 120 sandbox.getSubscriptionTitle = getSubscriptionTitle; |
120 | 121 |
121 // Clone template but remove id/hidden attributes from it | 122 // Clone template but remove id/hidden attributes from it |
122 let result = template.cloneNode(true); | 123 let result = template.cloneNode(true); |
123 result.removeAttribute("id"); | 124 result.removeAttribute("id"); |
124 result.removeAttribute("hidden"); | 125 result.removeAttribute("hidden"); |
125 result._data = data; | 126 result._data = data; |
126 | 127 |
127 // Resolve any attributes of the for attr="{obj.foo}" | 128 // Resolve any attributes of the for attr="{obj.foo}" |
128 let conditionals = []; | 129 let conditionals = []; |
129 let nodeIterator = document.createNodeIterator(result, NodeFilter.SHOW_ELEME
NT, null, false); | 130 let nodeIterator = document.createNodeIterator(result, NodeFilter.SHOW_ELEME
NT, null, false); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 * data object. | 218 * data object. |
218 */ | 219 */ |
219 getNodeForData: function(/**Node*/ parent, /**String*/ property, /**Object*/ d
ata) /**Node*/ | 220 getNodeForData: function(/**Node*/ parent, /**String*/ property, /**Object*/ d
ata) /**Node*/ |
220 { | 221 { |
221 for (let child = parent.firstChild; child; child = child.nextSibling) | 222 for (let child = parent.firstChild; child; child = child.nextSibling) |
222 if ("_data" in child && property in child._data && child._data[property] =
= data) | 223 if ("_data" in child && property in child._data && child._data[property] =
= data) |
223 return child; | 224 return child; |
224 return null; | 225 return null; |
225 } | 226 } |
226 }; | 227 }; |
OLD | NEW |