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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 /** | 54 /** |
55 * Abstract base class for filters | 55 * Abstract base class for filters |
56 * | 56 * |
57 * @param {string} text string representation of the filter | 57 * @param {string} text string representation of the filter |
58 * @constructor | 58 * @constructor |
59 */ | 59 */ |
60 function Filter(text) | 60 function Filter(text) |
61 { | 61 { |
62 this.text = text; | 62 this.text = text; |
63 | |
64 /** | |
65 * Subscriptions to which this filter belongs. | |
66 * @type {(Subscription|Set.<Subscription>)?} | |
67 * @private | |
68 */ | |
69 this._subscriptions = null; | |
70 } | 63 } |
71 exports.Filter = Filter; | 64 exports.Filter = Filter; |
72 | 65 |
73 Filter.prototype = | 66 Filter.prototype = |
74 { | 67 { |
75 /** | 68 /** |
76 * String representation of the filter | 69 * String representation of the filter |
77 * @type {string} | 70 * @type {string} |
78 */ | 71 */ |
79 text: null, | 72 text: null, |
80 | 73 |
81 /** | 74 /** |
82 * Filter type as a string, e.g. "blocking". | 75 * Filter type as a string, e.g. "blocking". |
83 * @type {string} | 76 * @type {string} |
84 */ | 77 */ |
85 get type() | 78 get type() |
86 { | 79 { |
87 throw new Error("Please define filter type in the subclass"); | 80 throw new Error("Please define filter type in the subclass"); |
88 }, | 81 }, |
89 | 82 |
90 /** | 83 /** |
| 84 * Subscriptions to which this filter belongs. |
| 85 * @type {(Subscription|Set.<Subscription>)?} |
| 86 * @private |
| 87 */ |
| 88 _subscriptions: null, |
| 89 |
| 90 /** |
| 91 * Whether the filter's subscriptions have already been added to the filter. |
| 92 * @type {boolean} |
| 93 * @package |
| 94 */ |
| 95 get subscriptionsAdded() |
| 96 { |
| 97 return this.hasOwnProperty("_subscriptions"); |
| 98 }, |
| 99 set subscriptionsAdded(value) |
| 100 { |
| 101 // Once set to true, this cannot be set back to false even if all |
| 102 // subscriptions are removed. |
| 103 if (value) |
| 104 this._subscriptions = this._subscriptions; |
| 105 }, |
| 106 |
| 107 /** |
91 * Yields subscriptions to which the filter belongs. | 108 * Yields subscriptions to which the filter belongs. |
92 * @yields {Subscription} | 109 * @yields {Subscription} |
93 */ | 110 */ |
94 *subscriptions() | 111 *subscriptions() |
95 { | 112 { |
96 if (this._subscriptions) | 113 if (this._subscriptions) |
97 { | 114 { |
98 if (this._subscriptions instanceof Set) | 115 if (this._subscriptions instanceof Set) |
99 yield* this._subscriptions; | 116 yield* this._subscriptions; |
100 else | 117 else |
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 | 1370 |
1354 /** | 1371 /** |
1355 * Script that should be executed | 1372 * Script that should be executed |
1356 * @type {string} | 1373 * @type {string} |
1357 */ | 1374 */ |
1358 get script() | 1375 get script() |
1359 { | 1376 { |
1360 return this.body; | 1377 return this.body; |
1361 } | 1378 } |
1362 }); | 1379 }); |
OLD | NEW |